private static bool TryParseHtmlTagCData(ref StringSlice text, ref ValueStringBuilder builder) { if (text.Match("[CDATA[")) { builder.Append("[CDATA["); text.Start += 6; char c = '\0'; while (true) { var pc = c; c = text.NextChar(); if (c == '\0') { return(false); } builder.Append(c); if (c == ']' && pc == ']' && text.PeekChar() == '>') { text.SkipChar(); text.SkipChar(); builder.Append('>'); return(true); } } } return(false); }
private static bool TryParseHtmlTagHtmlComment(ref StringSlice text, StringBuilder builder) { var c = text.NextChar(); if (c != '-') { return(false); } builder.Append('-'); builder.Append('-'); if (text.PeekChar() == '>') { return(false); } var countHyphen = 0; while (true) { c = text.NextChar(); if (c == '\0') { return(false); } if (countHyphen == 2) { if (c == '>') { builder.Append('>'); text.NextChar(); return(true); } return(false); } countHyphen = c == '-' ? countHyphen + 1 : 0; builder.Append(c); } }