Exemple #1
0
 public override void ExitHtmlElements(HTMLParser.HtmlElementsContext ctx)
 {
     var topNodeCtx = ctx.htmlElement();
     var expectedFullMarkup = MyTreeProperty.Get(topNodeCtx);
     FilteredPut(ctx, expectedFullMarkup);
 }
Exemple #2
0
        public override void ExitHtmlContent(HTMLParser.HtmlContentContext ctx)
        {
            var textContent = new StringBuilder();

            foreach(var elemCtx in ctx.htmlElement()){
                var elemText = MyTreeProperty.Get(elemCtx);
                if(string.IsNullOrEmpty(elemText)){
                    continue;
                }
                textContent.Append(elemText);
            }
            foreach (var charDataCtx in ctx.htmlChardata())
            {
                var cdataText = MyTreeProperty.Get(charDataCtx);
                if (string.IsNullOrWhiteSpace(cdataText))
                    continue;
                textContent.Append(cdataText);
            }

            FilteredPut(ctx, textContent.ToString());
        }