Example #1
0
        public void ParseNestedEmbeddingTest()
        {
            //Create parser
            EmbeddingParser embeddingParser = new EmbeddingParser(Init("\"pretext<em \"eerste\">midtext <em \"tweede\">posttexttail\""));
            Embedding       parsedEmbedding = embeddingParser.ParseEmbedding();

            //Test pretext
            Assert.AreEqual("\"pretext<", parsedEmbedding.GetPreText().ToString());

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

            Assert.AreEqual("em", expressionEmbed.GetMarkups().Get(0).ToString());
            Assert.AreEqual("\"eerste\"", expressionEmbed.GetExpression().ToString());

            //Test TextTail
            Assert.AreEqual(typeof(MidTextTail), parsedEmbedding.GetTextTail().GetType());
            MidTextTail midTextTail = (MidTextTail)parsedEmbedding.GetTextTail();

            Assert.AreEqual(">midtext <", midTextTail.GetMidText().ToString());

            //Test 2th embed
            Assert.AreEqual(typeof(ExpressionEmbed), midTextTail.GetEmbed().GetType());
            ExpressionEmbed expressionEmbed2 = (ExpressionEmbed)midTextTail.GetEmbed();

            Assert.AreEqual("em", expressionEmbed2.GetMarkups().Get(0).ToString());
            Assert.AreEqual("\"tweede\"", expressionEmbed2.GetExpression().ToString());

            //Test PostTextTail
            Assert.AreEqual(typeof(PostTextTail), midTextTail.GetTextTail().GetType());
            Assert.AreEqual(">posttexttail\"", midTextTail.GetTextTail().ToString());
        }
Example #2
0
        /// <summary>
        /// Interpret MidTextTail
        /// </summary>
        /// <param name="textTail">MidTextTail to Interpret</param>
        public override void Visit(MidTextTail textTail)
        {
            XHTMLElement element = new XHTMLElement(textTail.GetMidText().GetText(), Current);

            element.SetTagState(false);
            AddElement(element);

            textTail.GetEmbed().AcceptVisitor(this);
            textTail.GetTextTail().AcceptVisitor(this);
        }
Example #3
0
        /// <summary>
        /// Parser for TextTail
        /// </summary>
        /// <returns>Parsed TextTail</returns>
        public TextTail ParseTextTail()
        {
            TextTail textTail = null;

            //Skip > token
            NextToken(">", "> embedding tailsymbol", '>');

            //Parse text first to make type determination possible
            String parsedText = ParseTextChars();

            //Determine TextTail type
            if (EmbeddingTokenStream.HasNext() && EmbeddingTokenStream.Peek(1).GetValue().ToString() == "\"")
            {   //PostTextTail
                //Set PostText
                PostText postText = new PostText();
                postText.SetText(parsedText);

                //Create PostTextTail and fill it
                PostTextTail postTextTail = new PostTextTail();
                postTextTail.SetPostText(postText);

                //Skip Closing "
                NextToken("\"", "\"", '\"');

                textTail = postTextTail;
            }
            else
            {   //MidTextTail
                //Skip closing < tag of PreText
                NextToken("<", "< closing PreText", '<');

                //Set MidText
                MidText midText = new MidText();
                midText.SetText(parsedText);

                //Create MidTextTail object and fill it
                MidTextTail midTextTail = new MidTextTail();
                midTextTail.SetMidText(midText);
                midTextTail.SetEmbed(ParseEmbed());
                midTextTail.SetTextTail(ParseTextTail());

                textTail = midTextTail;
            }

            return(textTail);
        }
Example #4
0
 public virtual void Visit(MidTextTail textTail)
 {
     VisitSubNodes(textTail);
 }
Example #5
0
 public virtual void Visit(MidTextTail textTail)
 {
     VisitSubNodes(textTail);
 }
Example #6
0
        /// <summary>
        /// Parser for TextTail
        /// </summary>
        /// <returns>Parsed TextTail</returns>
        public TextTail ParseTextTail()
        {
            TextTail textTail = null;

            //Skip > token
            NextToken(">", "> embedding tailsymbol", '>');

            //Parse text first to make type determination possible
            String parsedText = ParseTextChars();

            //Determine TextTail type
            if (EmbeddingTokenStream.HasNext() && EmbeddingTokenStream.Peek(1).GetValue().ToString() == "\"")
            {   //PostTextTail

                //Set PostText
                PostText postText = new PostText();
                postText.SetText(parsedText);

                //Create PostTextTail and fill it
                PostTextTail postTextTail = new PostTextTail();
                postTextTail.SetPostText(postText);

                //Skip Closing "
                NextToken("\"", "\"", '\"');

                textTail = postTextTail;
            }
            else
            {   //MidTextTail

                //Skip closing < tag of PreText
                NextToken("<", "< closing PreText", '<');

                //Set MidText
                MidText midText = new MidText();
                midText.SetText(parsedText);

                //Create MidTextTail object and fill it
                MidTextTail midTextTail = new MidTextTail();
                midTextTail.SetMidText(midText);
                midTextTail.SetEmbed(ParseEmbed());
                midTextTail.SetTextTail(ParseTextTail());

                textTail = midTextTail;
            }

            return textTail;
        }