public void RwHtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_DirectiveName_NewLine_Content() { var input = @"@viewmodel test"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.DirectiveStart, tokenizer.Tokens[i++].Type); Assert.AreEqual("viewmodel", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.DirectiveName, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual("test", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_CommentParsing_Valid() { var input = @"test <!-- this is a text < > "" ' --> test2"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); // first line var i = 0; Assert.AreEqual("test ", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual("<!--", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.OpenComment, tokenizer.Tokens[i++].Type); Assert.AreEqual(@" this is a text < > "" ' ", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.CommentBody, tokenizer.Tokens[i++].Type); Assert.AreEqual("-->", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.CloseComment, tokenizer.Tokens[i++].Type); Assert.AreEqual(" test2", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public static RwHtmlRootNode ParseMarkup(string markup) { var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(markup)); var parser = new RwHtmlParser(); var node = parser.Parse(tokenizer.Tokens); return node; }
public void RwHtmlTokenizer_ElementParsing_Incomplete_OpenTag() { var input = @"<html"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_BindingParsing_Incomplete_OpenBinding() { var input = @"<input value=""{"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DoubleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenBinding, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.Colon, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.CloseBinding, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.DoubleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
protected override bool Execute(uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut, IOleCommandTarget nextCommandTarget) { var groupId = CommandGroupId; if (nextCommandTarget.Exec(ref groupId, nCmdID, nCmdexecopt, pvaIn, pvaOut) == VSConstants.S_OK) { // parse the content var tokenizer = new RwHtmlTokenizer(); var text = TextView.TextSnapshot.GetText(); tokenizer.Tokenize(new StringReader(text)); var parser = new RwHtmlParser(); var node = parser.Parse(tokenizer.Tokens); // prepare the metadata control resolver var completionSource = TextView.TextBuffer.Properties.GetProperty<RwHtmlCompletionSource>(typeof(RwHtmlCompletionSource)); var metadataControlResolver = completionSource.MetadataControlResolver; metadataControlResolver.ReloadAllControls(completionSource.GetCompletionContext()); try { CompletionHelper.DTE.UndoContext.Open("Format RWHTML document"); var edit = TextView.TextBuffer.CreateEdit(EditOptions.None, null, null); // fix the casing of all elements var editText = new StringBuilder(text); foreach (var element in node.EnumerateNodes().OfType<RwHtmlElementNode>()) { FixElement(editText, metadataControlResolver, TextView.TextBuffer, element); } edit.Replace(0, editText.Length, editText.ToString()); edit.Apply(); } finally { CompletionHelper.DTE.UndoContext.Close(); } } return true; }
public void RwHtmlTokenizer_DoctypeParsing_Invalid_Incomplete_NoValue() { var input = @"<!DOCTYPE"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); // first line var i = 0; Assert.AreEqual("<!DOCTYPE", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.OpenDoctype, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.DoctypeBody, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.CloseDoctype, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Invalid_AttributeName_MissingTagName() { var input = @"<a prefix:=''/>"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Colon, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.SingleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.SingleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_XmlProcessingInstructionParsing_Valid() { var input = @"test <?xml version=""1.0"" encoding=""utf-8"" ?> test2"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); // first line var i = 0; Assert.AreEqual("test ", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual("<?", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.OpenXmlProcessingInstruction, tokenizer.Tokens[i++].Type); Assert.AreEqual(@"xml version=""1.0"" encoding=""utf-8"" ", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.XmlProcessingInstructionBody, tokenizer.Tokens[i++].Type); Assert.AreEqual("?>", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.CloseXmlProcessingInstruction, tokenizer.Tokens[i++].Type); Assert.AreEqual(" test2", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_DoctypeParsing_Valid_End() { var input = @"test <!DOCTYPE html>"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); // first line var i = 0; Assert.AreEqual("test ", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual("<!DOCTYPE", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.OpenDoctype, tokenizer.Tokens[i++].Type); Assert.AreEqual(" html", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.DoctypeBody, tokenizer.Tokens[i++].Type); Assert.AreEqual(">", tokenizer.Tokens[i].Text); Assert.AreEqual(RwHtmlTokenType.CloseDoctype, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Invalid_CloseTag_TreatedAsText() { var input = @">"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Invalid_ElementName_MissingTagPrefix() { var input = @"<:name/>"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Colon, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_DirectiveParsing_Valid_TwoDirectives() { var input = @" @viewmodel Redwood.Samples.Sample1.IndexViewModel @masterpage ~/Site.rwhtml this is a test content"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); // first line var i = 0; Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DirectiveStart, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DirectiveName, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DirectiveStart, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DirectiveName, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Valid_SelfClosing_NoAttributes_TextOnEnd() { var input = @"<html/>aaa"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_DirectiveParsing_Invalid_OnlyAtSymbol() { var input = @"@"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.DirectiveStart, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.DirectiveName, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(RwHtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_BindingParsing_Valid_SelfClosing_BindingAttribute() { var input = @" tr <input value=""{binding: FirstName}"" />"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DoubleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenBinding, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Colon, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseBinding, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DoubleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Incomplete_OpenTag_AttributeName_Equals_Quote_Quote_AnotherTag() { var input = @"<html attr=''<a/>"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.SingleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.SingleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.IsTrue(tokenizer.Tokens[i].HasError); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_BindingParsing_Invalid_BindingInPlainText_SingleBraces_TreatedAsText() { var input = @"tr {binding: FirstName}test"" />"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(1, tokenizer.Tokens.Count); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Valid_AttributeWithoutValue() { var input = @" tr <input type=""checkbox"" checked />"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DoubleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.DoubleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Valid_SelfClosing_SingleQuotedAttribute() { var input = @" tr <html xmlns='hello dolly' />"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.SingleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.SingleQuote, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_DirectiveParsing_Valid_NoDirectives_WhiteSpaceOnStart() { var input = @" this is a test content"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); // first line var i = 0; Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_BindingParsing_Valid_BindingInPlainText() { var input = @"tr {{binding: FirstName}}"" />"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenBinding, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Colon, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseBinding, tokenizer.Tokens[i++].Type); }
public void RwHtmlTokenizer_ElementParsing_Valid_NestedTags_MultipleAttributes() { var input = @"<html><body lang=cs><h1 class=alert size=big>Test</h1> </body></html>"; // parse var tokenizer = new RwHtmlTokenizer(); tokenizer.Tokenize(new StringReader(input)); CheckForErrors(tokenizer, input.Length); var i = 0; Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Equals, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.OpenTag, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Slash, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.Text, tokenizer.Tokens[i++].Type); Assert.AreEqual(RwHtmlTokenType.CloseTag, tokenizer.Tokens[i++].Type); }