public override void ExitStyle(HTMLParser.StyleContext ctx) { const string SHORT_BODY = "</>"; const string BODY = "</style>"; var styleBody = ctx.STYLE_BODY() ?? ctx.STYLE_SHORT_BODY(); var styleBodyText = styleBody?.GetText(); if (string.IsNullOrWhiteSpace(styleBodyText)) { return; } if (styleBodyText.EndsWith(SHORT_BODY)) { styleBodyText = styleBodyText.Substring(0, styleBodyText.Length - SHORT_BODY.Length); } if (styleBodyText.EndsWith(BODY)) { styleBodyText = styleBodyText.Substring(0, styleBodyText.Length - BODY.Length); } styleBodyText = styleBodyText.Trim(); _results.StyleBodies.Add(styleBodyText); }
/// <summary> /// Exit a parse tree produced by <see cref="HTMLParser.style"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitStyle([NotNull] HTMLParser.StyleContext context) { }