Beispiel #1
0
        protected override void Write(HtmlComment node)
        {
            if (ShouldPretty())
            {
                writer.WriteLine();
                this.WriteIndent();
            }

            Write("<!--");
            Write(node.Slice.ToString());
            Write("-->");
        }
Beispiel #2
0
        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;
                }
            }
        }
Beispiel #3
0
        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;
                }
            }
        }
Beispiel #4
0
 protected override void Write(HtmlComment node)
 {
 }
Beispiel #5
0
 protected virtual void Write(HtmlComment node)
 {
     Write("<!--");
     Write(node.Slice.ToString());
     Write("-->");
 }
Beispiel #6
0
 protected override void Write(HtmlComment node)
 {
     Start("!com");
     base.Write(node);
     FlushDOM();
 }