/// <summary> /// See 8.2.4.26 Script data escaped end tag open state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken ScriptDataEscapedEndTag(Char c, HtmlTagToken tag) { if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return ScriptDataEscapedEndTag(src.Next, tag); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c); return ScriptDataEscapedEndTag(src.Next, tag); } EnqueueToken(HtmlToken.Character(Specification.LT)); EnqueueToken(HtmlToken.Character(Specification.SOLIDUS)); return ScriptDataEscaped(c); }
/// <summary> /// See 8.2.4.25 Script data escaped less-than sign state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataEscapedLT(Char c) { if (c == Specification.SOLIDUS) { return ScriptDataEndTag(src.Next); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); EnqueueToken(HtmlToken.Character(Specification.LT)); EnqueueToken(HtmlToken.Character(c)); return ScriptDataStartDoubleEscape(src.Next); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Clear(); stringBuffer.Append(c); EnqueueToken(HtmlToken.Character(Specification.LT)); EnqueueToken(HtmlToken.Character(c)); return ScriptDataStartDoubleEscape(src.Next); } EnqueueToken(HtmlToken.Character(Specification.LT)); return ScriptDataEscaped(c); }
/// <summary> /// See 8.2.4.18 Script data end tag open state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataEndTag(Char c) { if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return ScriptDataNameEndTag(src.Next, HtmlToken.CloseTag()); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c); return ScriptDataNameEndTag(src.Next, HtmlToken.CloseTag()); } EnqueueToken(HtmlToken.Characters(Specification.LT, Specification.SOLIDUS)); return ScriptData(c); }
/// <summary> /// See 8.2.4.34 Before attribute name state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken AttributeBeforeName(Char c, HtmlTagToken tag) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (c == Specification.SOLIDUS) { return TagSelfClosing(src.Next, tag); } else if (c == Specification.GT) { return EmitTag(tag); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return AttributeName(src.Next, tag); } else if (c == Specification.NULL) { RaiseErrorOccurred(ErrorCode.NULL); stringBuffer.Clear(); stringBuffer.Append(Specification.REPLACEMENT); return AttributeName(src.Next, tag); } else if (c == Specification.SQ || c == Specification.DQ || c == Specification.EQ || c == Specification.LT) { RaiseErrorOccurred(ErrorCode.AttributeNameInvalid); stringBuffer.Clear(); stringBuffer.Append(c); return AttributeName(src.Next, tag); } else if (c == Specification.EOF) { return HtmlToken.EOF; } else { stringBuffer.Clear(); stringBuffer.Append(c); return AttributeName(src.Next, tag); } }
/// <summary> /// See 8.2.4.8 Tag open state /// </summary> /// <param name="c">The next input character.</param> HtmlToken TagOpen(Char c) { if (c == Specification.EM) { return MarkupDeclaration(src.Next); } else if (c == Specification.SOLIDUS) { return TagEnd(src.Next); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return TagName(src.Next, HtmlToken.OpenTag()); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c); return TagName(src.Next, HtmlToken.OpenTag()); } else if (c == Specification.QM) { RaiseErrorOccurred(ErrorCode.BogusComment); return BogusComment(c); } else { model = HtmlParseMode.PCData; RaiseErrorOccurred(ErrorCode.AmbiguousOpenTag); return HtmlToken.Character(Specification.LT); } }
public static Char ToLower(this Char c, CultureInfo culture) { return(Char.ToLower(c, culture)); }
/// <summary> /// See 8.2.4.54 DOCTYPE name state /// </summary> /// <param name="c">The next input character.</param> /// <param name="doctype">The current doctype token.</param> /// <returns>The emitted token.</returns> HtmlToken DoctypeName(Char c, HtmlDoctypeToken doctype) { while (true) { if (Specification.IsSpaceCharacter(c)) { doctype.Name = stringBuffer.ToString(); return DoctypeNameAfter(src.Next, doctype); } else if (c == Specification.GT) { model = HtmlParseMode.PCData; doctype.Name = stringBuffer.ToString(); return doctype; } else if (Specification.IsUppercaseAscii(c)) stringBuffer.Append(c.ToLower()); else if (c == Specification.NULL) { RaiseErrorOccurred(ErrorCode.NULL); stringBuffer.Append(Specification.REPLACEMENT); } else if (c == Specification.EOF) { RaiseErrorOccurred(ErrorCode.EOF); src.Back(); doctype.IsQuirksForced = true; doctype.Name = stringBuffer.ToString(); return doctype; } else stringBuffer.Append(c); c = src.Next; } }
/// <summary> /// See 8.2.4.9 End tag open state /// </summary> /// <param name="c">The next input character.</param> HtmlToken TagEnd(Char c) { if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return TagName(src.Next, HtmlToken.CloseTag()); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c); return TagName(src.Next, HtmlToken.CloseTag()); } else if (c == Specification.GT) { model = HtmlParseMode.PCData; RaiseErrorOccurred(ErrorCode.TagClosedWrong); return Data(src.Next); } else if (c == Specification.EOF) { src.Back(); RaiseErrorOccurred(ErrorCode.EOF); return HtmlToken.Characters(Specification.LT, Specification.SOLIDUS); } else { RaiseErrorOccurred(ErrorCode.BogusComment); return BogusComment(c); } }
/// <summary> /// See 8.2.4.19 Script data end tag name state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken ScriptDataNameEndTag(Char c, HtmlTagToken tag) { var name = _stringBuffer.ToString(); var appropriateEndTag = name == _lastStartTag; if (appropriateEndTag && c.IsSpaceCharacter()) { tag.Name = name; return AttributeBeforeName(_src.Next, tag); } else if (appropriateEndTag && c == Specification.SOLIDUS) { tag.Name = name; return TagSelfClosing(_src.Next, tag); } else if (appropriateEndTag && c == Specification.GT) { tag.Name = name; return EmitTag(tag); } else if (c.IsUppercaseAscii()) { _stringBuffer.Append(c.ToLower()); return ScriptDataNameEndTag(_src.Next, tag); } else if (c.IsLowercaseAscii()) { _stringBuffer.Append(c); return ScriptDataNameEndTag(_src.Next, tag); } _buffer.Append(Specification.LT).Append(Specification.SOLIDUS); _buffer.Append(_stringBuffer.ToString()); return ScriptData(c); }
/// <summary> /// See 8.2.4.28 Script data double escape start state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataStartDoubleEscape(Char c) { if (c.IsSpaceCharacter() || c == Specification.SOLIDUS || c == Specification.GT) { _buffer.Append(c); if (_stringBuffer.ToString() == "script") return ScriptDataEscapedDouble(_src.Next); return ScriptDataEscaped(_src.Next); } else if (c.IsUppercaseAscii()) { _stringBuffer.Append(c.ToLower()); _buffer.Append(c); return ScriptDataStartDoubleEscape(_src.Next); } else if (c.IsLowercaseAscii()) { _stringBuffer.Append(c); _buffer.Append(c); return ScriptDataStartDoubleEscape(_src.Next); } return ScriptDataEscaped(c); }
/// <summary> /// See 8.2.4.25 Script data escaped less-than sign state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataEscapedLT(Char c) { if (c == Specification.SOLIDUS) { return ScriptDataEndTag(_src.Next); } else if (c.IsUppercaseAscii()) { _stringBuffer.Clear(); _stringBuffer.Append(c.ToLower()); _buffer.Append(Specification.LT); _buffer.Append(c); return ScriptDataStartDoubleEscape(_src.Next); } else if (c.IsLowercaseAscii()) { _stringBuffer.Clear(); _stringBuffer.Clear(); _stringBuffer.Append(c); _buffer.Append(Specification.LT); _buffer.Append(c); return ScriptDataStartDoubleEscape(_src.Next); } _buffer.Append(Specification.LT); return ScriptDataEscaped(c); }
/// <summary> /// See 8.2.4.26 Script data escaped end tag open state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken ScriptDataEscapedEndTag(Char c, HtmlTagToken tag) { if (c.IsUppercaseAscii()) { _stringBuffer.Clear(); _stringBuffer.Append(c.ToLower()); return ScriptDataEscapedEndTag(_src.Next, tag); } else if (c.IsLowercaseAscii()) { _stringBuffer.Clear(); _stringBuffer.Append(c); return ScriptDataEscapedEndTag(_src.Next, tag); } _buffer.Append(Specification.LT).Append(Specification.SOLIDUS); return ScriptDataEscaped(c); }
/// <summary> /// See 8.2.4.18 Script data end tag open state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataEndTag(Char c) { if (c.IsUppercaseAscii()) { _stringBuffer.Clear(); _stringBuffer.Append(c.ToLower()); return ScriptDataNameEndTag(_src.Next, HtmlToken.CloseTag()); } else if (c.IsLowercaseAscii()) { _stringBuffer.Clear(); _stringBuffer.Append(c); return ScriptDataNameEndTag(_src.Next, HtmlToken.CloseTag()); } _buffer.Append(Specification.LT).Append(Specification.SOLIDUS); return ScriptData(c); }
/// <summary> /// See 8.2.4.19 Script data end tag name state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken ScriptDataNameEndTag(Char c, HtmlTagToken tag) { var name = stringBuffer.ToString(); var appropriateEndTag = name == lastStartTag; if (appropriateEndTag && Specification.IsSpaceCharacter(c)) { tag.Name = name; return AttributeBeforeName(src.Next, tag); } else if (appropriateEndTag && c == Specification.SOLIDUS) { tag.Name = name; return TagSelfClosing(src.Next, tag); } else if (appropriateEndTag && c == Specification.GT) { tag.Name = name; return EmitTag(tag); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Append(c.ToLower()); return ScriptDataNameEndTag(src.Next, tag); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Append(c); return ScriptDataNameEndTag(src.Next, tag); } stringBuffer.Insert(0, Specification.LT).Insert(1, Specification.SOLIDUS); EnqueueToken(HtmlToken.Characters(stringBuffer.ToString())); return ScriptData(c); }
/// <summary> /// See 8.2.4.53 Before DOCTYPE name state /// </summary> /// <param name="c">The next input character.</param> HtmlToken DoctypeNameBefore(Char c) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return DoctypeName(src.Next, HtmlToken.Doctype(false)); } else if (c == Specification.NULL) { RaiseErrorOccurred(ErrorCode.NULL); stringBuffer.Clear(); stringBuffer.Append(Specification.REPLACEMENT); return DoctypeName(src.Next, HtmlToken.Doctype(false)); } else if (c == Specification.GT) { model = HtmlParseMode.PCData; RaiseErrorOccurred(ErrorCode.TagClosedWrong); return HtmlToken.Doctype(true); } else if (c == Specification.EOF) { RaiseErrorOccurred(ErrorCode.EOF); src.Back(); return HtmlToken.Doctype(true); } stringBuffer.Clear(); stringBuffer.Append(c); return DoctypeName(src.Next, HtmlToken.Doctype(false)); }
/// <summary> /// See 8.2.4.28 Script data double escape start state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataStartDoubleEscape(Char c) { if (Specification.IsSpaceCharacter(c)) { if (stringBuffer.ToString() == "script") return ScriptDataEscapedDouble(src.Next); EnqueueToken(HtmlToken.Character(c)); return ScriptDataEscaped(src.Next); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Append(c.ToLower()); EnqueueToken(HtmlToken.Character(c)); return ScriptDataStartDoubleEscape(src.Next); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Append(c); EnqueueToken(HtmlToken.Character(c)); return ScriptDataStartDoubleEscape(src.Next); } return ScriptDataEscaped(c); }
/// <summary> /// See 8.2.4.12 RCDATA end tag open state /// </summary> /// <param name="c">The next input character.</param> /// <returns>The emitted token.</returns> HtmlToken RCDataEndTag(Char c) { if (Specification.IsUppercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c.ToLower()); return RCDataNameEndTag(src.Next, HtmlToken.CloseTag()); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Clear(); stringBuffer.Append(c); return RCDataNameEndTag(src.Next, HtmlToken.CloseTag()); } else { src.Back(); return HtmlToken.Characters(Specification.LT, Specification.SOLIDUS); } }
/// <summary> /// See 8.2.4.10 Tag name state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken TagName(Char c, HtmlTagToken tag) { if (Specification.IsSpaceCharacter(c)) { tag.Name = stringBuffer.ToString(); return AttributeBeforeName(src.Next, tag); } else if (c == Specification.SOLIDUS) { tag.Name = stringBuffer.ToString(); return TagSelfClosing(src.Next, tag); } else if (c == Specification.GT) { tag.Name = stringBuffer.ToString(); return EmitTag(tag); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Append(c.ToLower()); return TagName(src.Next, tag); } else if (c == Specification.NULL) { RaiseErrorOccurred(ErrorCode.NULL); stringBuffer.Append(Specification.REPLACEMENT); return TagName(src.Next, tag); } else if (c == Specification.EOF) { RaiseErrorOccurred(ErrorCode.EOF); return HtmlToken.EOF; } else { stringBuffer.Append(c); return TagName(src.Next, tag); } }
/// <summary> /// See 8.2.4.33 Script data double escape end state /// </summary> /// <param name="c">The next input character.</param> HtmlToken ScriptDataEndDoubleEscape(Char c) { if (Specification.IsSpaceCharacter(c) || c == Specification.SOLIDUS || c == Specification.GT) { if (stringBuffer.ToString().Equals("script", StringComparison.OrdinalIgnoreCase)) return ScriptDataEscaped(src.Next); EnqueueToken(HtmlToken.Character(c)); return ScriptDataEscapedDouble(src.Next); } else if (Specification.IsUppercaseAscii(c)) { stringBuffer.Append(c.ToLower()); EnqueueToken(HtmlToken.Character(c)); return ScriptDataEndDoubleEscape(src.Next); } else if (Specification.IsLowercaseAscii(c)) { stringBuffer.Append(c); EnqueueToken(HtmlToken.Character(c)); return ScriptDataEndDoubleEscape(src.Next); } return ScriptDataEscapedDouble(c); }
/// <summary> /// See 8.2.4.35 Attribute name state /// </summary> /// <param name="c">The next input character.</param> /// <param name="tag">The current tag token.</param> /// <returns>The emitted token.</returns> HtmlToken AttributeName(Char c, HtmlTagToken tag) { while (true) { if (Specification.IsSpaceCharacter(c)) { tag.AddAttribute(stringBuffer.ToString()); return AttributeAfterName(src.Next, tag); } else if (c == Specification.SOLIDUS) { tag.AddAttribute(stringBuffer.ToString()); return TagSelfClosing(src.Next, tag); } else if (c == Specification.EQ) { tag.AddAttribute(stringBuffer.ToString()); return AttributeBeforeValue(src.Next, tag); } else if (c == Specification.GT) { tag.AddAttribute(stringBuffer.ToString()); return EmitTag(tag); } else if (Specification.IsUppercaseAscii(c)) stringBuffer.Append(c.ToLower()); else if (c == Specification.NULL) { RaiseErrorOccurred(ErrorCode.NULL); stringBuffer.Append(Specification.REPLACEMENT); } else if (c == Specification.DQ || c == Specification.SQ || c == Specification.LT) { RaiseErrorOccurred(ErrorCode.AttributeNameInvalid); stringBuffer.Append(c); } else if (c == Specification.EOF) return HtmlToken.EOF; else stringBuffer.Append(c); c = src.Next; } }
public static Char ToLower(this Char c) { return(Char.ToLower(c)); }