Exemple #1
0
        public void Simple()
        {
            var document = TestUtils.Test("blockquote_simple");

            Assert.Equal(2, document.Elements.Count);
            Paragraph paragraph = (Paragraph)document.Elements[0];

            Assert.Equal("Line 1.\n", paragraph.TextAreas[0].Content.Text);
            Assert.Equal("Line 2.\n", paragraph.TextAreas[1].Content.Text);
            BlockQuote element = (BlockQuote)document.Elements[1];

            Assert.True(element.TypeCode == ElementType.BlockQuote);
            Paragraph paragraph3 = (Paragraph)element.Elements[0];

            Assert.Equal("Indented.\n", paragraph3.TextAreas[0].Content.Text);
        }
        /// <summary>
        /// Creates a new instance of <see cref="BlockElement"/>.
        /// Its type will be determined with the specified first line.
        /// </summary>
        /// <param name="line">The line which is the first line of the block.</param>
        /// <param name="currentIndent">The indent count of <paramref name="line"/>.</param>
        /// <param name="config">Configuration of the parser.</param>
        /// <param name="createListItem">
        /// Creates a <see cref="ListItem"/> instead of <see cref="ListBlock"/> when <c>true</c> is specified.
        /// </param>
        /// <returns>The new element that the type corresponds to <paramref name="line"/>.</returns>
        public static BlockElement CreateBlockFromLine(string line, int currentIndent, ParserConfig config,
                                                       bool createListItem = false)
        {
            if (IndentedCodeBlock.CanStartBlock(line, currentIndent))
            {
                return(new IndentedCodeBlock(config));
            }

            if (ThematicBreak.CanStartBlock(line, currentIndent))
            {
                return(new ThematicBreak(config));
            }

            if (AtxHeading.CanStartBlock(line, currentIndent))
            {
                return(new AtxHeading(config));
            }

            if (FencedCodeBlock.CanStartBlock(line, currentIndent))
            {
                return(new FencedCodeBlock(config));
            }

            if (HtmlBlock.CanStartBlock(line, currentIndent))
            {
                return(new HtmlBlock(config));
            }

            if (BlockQuote.CanStartBlock(line, currentIndent))
            {
                return(new BlockQuote(config));
            }

            if (ListBlock.CanStartBlock(line, currentIndent))
            {
                return(createListItem ? (BlockElement) new ListItem(config) : new ListBlock(config));
            }

            if (BlankLine.CanStartBlock(line))
            {
                return(new BlankLine(config));
            }

            return(new UnknownElement(config));
        }
Exemple #3
0
 private static void BlockQuote(MarkdownProcessorContext context, BlockQuote node)
 {
     if (!string.IsNullOrEmpty(node.Info))
     {
         context.Write(MARKDOWN_BLOCKQUOTE);
         context.Write("[!");
         context.Write(node.Info.ToUpper());
         context.WriteLine("]");
     }
     if (!string.IsNullOrEmpty(node.Title))
     {
         context.Write(MARKDOWN_BLOCKQUOTE);
         context.WriteLine(node.Title);
     }
     foreach (var line in node.Content)
     {
         context.Write(MARKDOWN_BLOCKQUOTE);
         context.WriteLine(line);
     }
     context.LineBreak();
 }
Exemple #4
0
        public void Nested2()
        {
            var document = TestUtils.Test("blockquote_nested2");

            Assert.Equal(3, document.Elements.Count);
            Paragraph paragraph = (Paragraph)document.Elements[0];

            Assert.Equal("Here is a paragraph.\n", paragraph.TextAreas[0].Content.Text);
            BlockQuote element = (BlockQuote)document.Elements[1];

            Assert.True(element.TypeCode == ElementType.BlockQuote);
            BlockQuote block2 = (BlockQuote)element.Elements[0];

            Assert.Equal("Indent 8 spaces.\n", block2.TextAreas[0].Content.Text);
            Paragraph paragraph3 = (Paragraph)element.Elements[1];

            Assert.Equal(ElementType.Paragraph, paragraph3.TypeCode);
            Assert.Equal("Indent 4 spaces.\n", paragraph3.TextAreas[0].Content.Text);
            Assert.Equal("Is this correct? Should it generate a warning?\n", document.Elements[2].TextAreas[0].Content.Text);
            Assert.Equal("Yes, it is correct, no warning necessary.\n", document.Elements[2].TextAreas[1].Content.Text);
        }
Exemple #5
0
        public void Nested()
        {
            var document = TestUtils.Test("blockquote_nested");

            Assert.Equal(2, document.Elements.Count);
            Paragraph paragraph = (Paragraph)document.Elements[0];

            Assert.Equal("Line 1.\n", paragraph.TextAreas[0].Content.Text);
            Assert.Equal("Line 2.\n", paragraph.TextAreas[1].Content.Text);
            BlockQuote block = (BlockQuote)document.Elements[1];

            Assert.True(block.TypeCode == ElementType.BlockQuote);
            Paragraph paragraph2 = (Paragraph)block.Elements[0];

            Assert.Equal("Indented 1.\n", paragraph2.TextAreas[0].Content.Text);
            BlockQuote blockQuote = (BlockQuote)block.Elements[1];

            Assert.Equal(ElementType.BlockQuote, blockQuote.TypeCode);
            Paragraph paragraph3 = (Paragraph)blockQuote.Elements[0];

            Assert.Equal("Indented 2.\n", paragraph3.TextAreas[0].Content.Text);
        }
Exemple #6
0
        public void DefinitionList()
        {
            var document = TestUtils.Test("blockquote_definitionlist");

            Assert.Equal(6, document.Elements.Count);
            {
                Paragraph paragraph = (Paragraph)document.Elements[0];
                Assert.Equal("Paragraph.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[1];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("-- Not an attribution\n", paragraph2.TextAreas[0].Content.Text);
                Assert.Null(element.Attribution);
            }
            {
                Paragraph paragraph = (Paragraph)document.Elements[2];
                Assert.Equal("Paragraph.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[3];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote.\n", paragraph2.TextAreas[0].Content.Text);
                Assert.Null(element.Attribution);
                Paragraph paragraph3 = (Paragraph)element.Elements[1];
                Assert.Equal("\\-- Not an attribution\n", paragraph3.TextAreas[0].Content.Text);
            }
            {
                Paragraph paragraph = (Paragraph)document.Elements[4];
                Assert.Equal("Paragraph.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[5];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote.\n", paragraph2.TextAreas[0].Content.Text);
                Assert.Null(element.Attribution);
                DefinitionList list  = (DefinitionList)element.Elements[1];
                var            item1 = list.Items[0];
                Assert.Equal("-- Not an attribution line one", item1.Term.TextAreas[0].Content.Text);
                var list2 = (DefinitionList)item1.Definition.Elements[0];
                var item2 = list2.Items[0];
                Assert.Equal("and line two", item2.Term.TextAreas[0].Content.Text);
                Assert.Equal("and line three\n", item2.Definition.Elements[0].TextAreas[0].Content.Text);
            }
        }
Exemple #7
0
        public void AttributionSimple2()
        {
            var document = TestUtils.Test("blockquote_attribution_simple2");

            Assert.Equal(3, document.Elements.Count);
            Paragraph paragraph = (Paragraph)document.Elements[0];

            Assert.Equal("Paragraph.\n", paragraph.TextAreas[0].Content.Text);
            {
                BlockQuote element    = (BlockQuote)document.Elements[1];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote 1.\n", paragraph2.TextAreas[0].Content.Text);
                Attribution attribution = element.Attribution;
                Assert.Equal("Attribution 1\n", attribution.TextAreas[0].Content.Text);
            }
            {
                BlockQuote element    = (BlockQuote)document.Elements[2];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote 2.\n", paragraph2.TextAreas[0].Content.Text);
                Assert.Null(element.Attribution);
            }
        }
Exemple #8
0
        public void Attribution()
        {
            var document = TestUtils.Test("blockquote_attribution");

            Assert.Equal(4, document.Elements.Count);
            {
                Paragraph paragraph = (Paragraph)document.Elements[0];
                Assert.Equal("Paragraph.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[1];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote.\n", paragraph2.TextAreas[0].Content.Text);
                Attribution attribution = element.Attribution;
                Assert.Equal("Attribution\n", attribution.TextAreas[0].Content.Text);
            }
            {
                Paragraph paragraph = (Paragraph)document.Elements[2];
                Assert.Equal("Paragraph.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[3];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote.\n", paragraph2.TextAreas[0].Content.Text);
                Attribution attribution = element.Attribution;
                Assert.Equal("Attribution\n", attribution.TextAreas[0].Content.Text);
            }
        }
Exemple #9
0
        public void AttributionEmDash()
        {
            var document = TestUtils.Test("blockquote_attribution_emdash");

            Assert.Equal(4, document.Elements.Count);
            {
                Paragraph paragraph = (Paragraph)document.Elements[0];
                Assert.Equal("Alternative: true em-dash.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[1];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote.\n", paragraph2.TextAreas[0].Content.Text);
                Attribution attribution = element.Attribution;
                Assert.Equal("Attribution\n", attribution.TextAreas[0].Content.Text);
            }
            {
                Paragraph paragraph = (Paragraph)document.Elements[2];
                Assert.Equal("Alternative: three hyphens.\n", paragraph.TextAreas[0].Content.Text);
                BlockQuote element    = (BlockQuote)document.Elements[3];
                Paragraph  paragraph2 = (Paragraph)element.Elements[0];
                Assert.Equal("Block quote.\n", paragraph2.TextAreas[0].Content.Text);
                Attribution attribution = element.Attribution;
                Assert.Equal("Attribution\n", attribution.TextAreas[0].Content.Text);
            }
        }
 public void EndBlockQuote(BlockQuote blockqoute)
 {
     indent -= IndentBy;
 }
 public override BlockQuote VisitBlockQuote(BlockQuote blockQuote)
 {
     blockQuote = blockQuoteDelegate?.Invoke(blockQuote) ?? blockQuote;
     return(base.VisitBlockQuote(blockQuote));
 }
Exemple #12
0
        public void Is_Passed_An_Object_Of_IHtmlControl_That_Is_Of_BlockQuote_Then_Supports_Content_Returns_True(BlockQuote quote, BlockQuoteControlRenderer renderer)
        {
            var actual = renderer.SupportsContent(quote);

            actual.Should().BeTrue();
        }
 public void EndBlockQuote(BlockQuote blockqoute)
 {
     PopPrefix();
 }
 public void EndBlockQuote(BlockQuote blockqoute)
 {
     writer.WriteLine("</blockquote>");
 }
 public void StartBlockQuote(BlockQuote blockqoute)
 {
     EnsureNewlineEnding(writer);
     writer.WriteLine("<blockquote>");
 }
 public void StartBlockQuote(BlockQuote blockqoute)
 {
     PushPrefix("> ");
 }
 public void StartBlockQuote(BlockQuote blockqoute)
 {
     Write("block_quote");
     indent += IndentBy;
 }
 protected override void BeginProcessing()
 {
     _Builder    = GetBuilder();
     _BlockQuote = GetBuilder().BlockQuote(GetInfo(), Title);
     _Content    = new List <string>();
 }
Exemple #19
0
 internal BlockQuoteElement(BlockQuote blockQuote) : base(blockQuote)
 {
     this.DefaultStyleKey = typeof(BlockQuoteElement);
 }