Example #1
0
        public void ParseEmbeddingTest()
        {
            //Create parser
            EmbeddingParser embeddingParser = new EmbeddingParser(Init("\"left<func1() \"text\">right\""));
            Embedding       parsedEmbedding = embeddingParser.ParseEmbedding();

            //Test PreText
            Assert.AreEqual("left", parsedEmbedding.GetPreText().GetText());

            //Test Embed
            Assert.AreEqual(typeof(ExpressionEmbed), parsedEmbedding.GetEmbed().GetType());
            ExpressionEmbed expressionEmbed = (ExpressionEmbed)parsedEmbedding.GetEmbed();

            Assert.AreEqual("\"text\"", expressionEmbed.GetExpression().ToString());

            //Test Markup
            Markup markup = (Markup)expressionEmbed.GetMarkups().Get(0);

            Assert.AreEqual("func1", markup.GetDesignator().ToString());
            Assert.AreEqual(0, markup.GetArguments().Count);

            //Test TextTail
            Assert.AreEqual(typeof(PostTextTail), parsedEmbedding.GetTextTail().GetType());
            PostTextTail postTextTail = (PostTextTail)parsedEmbedding.GetTextTail();

            Assert.AreEqual("right", postTextTail.GetPostText().GetText());
        }
Example #2
0
        /// <summary>
        /// Interpret PostTextTail
        /// </summary>
        /// <param name="textTail">PostTextTail to interpret</param>
        public override void Visit(PostTextTail textTail)
        {
            XHTMLElement element = new XHTMLElement(textTail.GetPostText().GetText(), Current);

            element.SetTagState(false);
            AddElement(element);
        }
Example #3
0
        public void ParserMarkupEmbeddingStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("p p \"left<func1() \"text\">right\";"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statement
            Assert.AreEqual(typeof(MarkupEmbeddingStatement), parsedStatement.GetType());

            //Test MarkupEmbeddingStatement
            MarkupEmbeddingStatement markupEmbeddingStatement = (MarkupEmbeddingStatement)parsedStatement;

            Assert.AreEqual("p", markupEmbeddingStatement.GetMarkups().Get(0).ToString());
            Assert.AreEqual("p", markupEmbeddingStatement.GetMarkups().Get(1).ToString());

            //Test embedding
            Embedding embedding = markupEmbeddingStatement.GetEmbedding();

            Assert.AreEqual("\"left<", embedding.GetPreText().ToString());
            Assert.AreEqual(typeof(ExpressionEmbed), embedding.GetEmbed().GetType());

            ExpressionEmbed embed = (ExpressionEmbed)embedding.GetEmbed();

            Assert.AreEqual(1, embed.GetMarkups().Count);
            Assert.AreEqual("func1", embed.GetMarkups().Get(0).ToString());
            Assert.AreEqual(typeof(TextExpression), embed.GetExpression().GetType());
            Assert.AreEqual("\"text\"", embed.GetExpression().ToString());

            Assert.AreEqual(typeof(PostTextTail), embedding.GetTextTail().GetType());
            PostTextTail postTextTail = (PostTextTail)embedding.GetTextTail();

            Assert.AreEqual(">right\"", postTextTail.GetPostText().ToString());
        }