Пример #1
0
        public override void ExitScript(HTMLParser.ScriptContext ctx)
        {
            const string SHORT_BODY = "</>";
            const string BODY = "</script>";
            var scriptBodyNode = ctx.SCRIPT_BODY() ?? ctx.SCRIPT_SHORT_BODY();
            var scriptBodyText = scriptBodyNode?.GetText();
            if (string.IsNullOrWhiteSpace(scriptBodyText))
                return;
            if (scriptBodyText.EndsWith(SHORT_BODY))
                scriptBodyText = scriptBodyText.Substring(0, scriptBodyText.Length - (SHORT_BODY.Length));
            if (scriptBodyText.EndsWith(BODY))
                scriptBodyText = scriptBodyText.Substring(0, scriptBodyText.Length - (BODY.Length));

            scriptBodyText = scriptBodyText.Trim();
            _results.ScriptBodies.Add(scriptBodyText);
        }