protected override void Write(HtmlComment node) { if (ShouldPretty()) { writer.WriteLine(); this.WriteIndent(); } Write("<!--"); Write(node.Slice.ToString()); Write("-->"); }
private void TryProcessComment() { c = NextChar(); if (c != '-') { AppendText(startTagLocation, position - 1); return; } var commentPosition = position + 1; while (true) { c = NextChar(); if (c == '-') { c = NextChar(); if (c == '-') { c = NextChar(); if (c == '>') { // Don't eat last char, as it will be processed by main loop c = NextChar(); var comment = new HtmlComment() { Location = startTagLocation, Slice = new StringSlice(text, commentPosition, position - 4) }; CurrentParent.AppendChild(comment); return; } Error(c == 0 ? $"Invalid EOF found while parsing <!--" : $"Invalid character '{c}' found while parsing <!--"); AppendText(startTagLocation, position - 1); return; } } if (c == '\0') { Error($"Invalid EOF found while parsing comment"); AppendText(startTagLocation, position - 1); return; } } }
void TryProcessComment() { c = NextChar(); if (c != '-') { AppendText(startTagLocation, position - 1); return; } var commentPosition = position + 1; var hyphenCount = 0; while (true) { c = NextChar(); if (hyphenCount >= 2 && c == '>') { c = NextChar(); var comment = new HtmlComment { Location = startTagLocation, Slice = new StringSlice(text, commentPosition, position - 4) }; CurrentParent.AppendChild(comment); return; } if (c == '-') { hyphenCount++; } else { hyphenCount = 0; } if (c == '\0') { Error($"Invalid EOF found while parsing comment"); AppendText(startTagLocation, position - 1); return; } } }
protected override void Write(HtmlComment node) { }
protected virtual void Write(HtmlComment node) { Write("<!--"); Write(node.Slice.ToString()); Write("-->"); }
protected override void Write(HtmlComment node) { Start("!com"); base.Write(node); FlushDOM(); }