Exemple #1
0
        public static void MarkdownWriter_WriteHeading(int level)
        {
            MarkdownWriter mw = CreateWriter(new MarkdownFormat(headingOptions: HeadingOptions.None));

            mw.WriteHeading(level, Value);

            Assert.Equal($"{new string('#', level)} {ValueEscaped}{NewLine}", mw.ToStringAndClear());
        }
Exemple #2
0
        public static void MarkdownWriter_WriteBlockQuote(string text1, string text2)
        {
            MarkdownWriter mw = CreateWriter();

            mw.WriteBlockQuote(text1);

            Assert.Equal(text2, mw.ToStringAndClear());
        }
Exemple #3
0
        public static void MarkdownWriter_WriteHeading6(HeadingOptions?options)
        {
            MarkdownWriter mw = CreateBuilderWithHeadingOptions(options);

            mw.WriteHeading6(Value);

            Assert.Equal($"###### {ValueEscaped}{NewLine2}", mw.ToStringAndClear());
        }
Exemple #4
0
        public static void MarkdownWriter_WriteInlineCode3()
        {
            MarkdownWriter mw = CreateWriter();

            mw.WriteInlineCode("`` ``` ``");

            Assert.Equal("` `` ``` `` `", mw.ToStringAndClear());
        }
Exemple #5
0
        public static void MarkdownWriter_Write_Italic(string syntax, EmphasisStyle?italicStyle)
        {
            const string   x  = Chars;
            const string   y  = CharsEscaped;
            MarkdownWriter mw = CreateBuilderWithItalicStyle(italicStyle);

            mw.Write(Italic(x));

            Assert.Equal(syntax + y + syntax, mw.ToStringAndClear());
        }
Exemple #6
0
        public static void MarkdownWriter_WriteInlineCode_WithoutBacktick()
        {
            const string   x  = CharsWithoutBacktick;
            const string   y  = CharsWithoutBacktick;
            MarkdownWriter mw = CreateWriter();

            mw.WriteInlineCode(x);

            Assert.Equal("`" + y + "`", mw.ToStringAndClear());
        }
Exemple #7
0
        public static void MarkdownWriter_Write_InlineCode()
        {
            const string   x  = CharsEnclosedWithBacktick;
            const string   y  = CharsEnclosedWithBacktick;
            MarkdownWriter mw = CreateWriter();

            mw.Write(InlineCode(x));

            Assert.Equal("`` " + y + " ``", mw.ToStringAndClear());
        }
Exemple #8
0
        public static void MarkdownWriter_Write_Strikethrough()
        {
            const string   x  = Chars;
            const string   y  = CharsEscaped;
            MarkdownWriter mw = CreateWriter();

            mw.Write(Strikethrough(x));

            Assert.Equal("~~" + y + "~~", mw.ToStringAndClear());
        }
Exemple #9
0
        public static void MarkdownWriter_WriteCompletedTaskItem(string text, string text2)
        {
            MarkdownWriter mw       = CreateWriter();
            const string   start    = "- [x] ";
            string         expected = start + text2 + CharsEscaped + NewLine + "  " + start + text2 + NewLine;
            MTaskItem      item     = CompletedTaskItem(text + Chars, CompletedTaskItem(text));

            item.WriteTo(mw);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #10
0
        public static void MarkdownWriter_Write_BulletItem(string syntax, BulletListStyle?style)
        {
            MarkdownWriter mw       = CreateBuilderWithBulletItemStyle(style);
            const string   text     = "BulletItemText";
            string         expected = syntax + " " + text + CharsEscaped + NewLine + "  " + syntax + " " + text + NewLine;
            MBulletItem    item     = BulletItem(text + Chars, BulletItem(text));

            mw.Write(item);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #11
0
        public static void MarkdownWriter_Write_CodeBlock_CodeFenceStyle(string syntax, CodeFenceStyle?style)
        {
            MarkdownWriter mw = CreateBuilderWithCodeFenceOptions(style);

            MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText);

            block.WriteTo(mw);

            Assert.Equal(
                syntax + DefaultText + NewLine + Chars + NewLine + syntax + NewLine2,
                mw.ToStringAndClear());
        }
Exemple #12
0
        public static void MarkdownWriter_Write_OrderedItem(int number, string indentation)
        {
            MarkdownWriter mw = CreateWriter();

            const string text = "OrderedItemText";

            string       expected = number + ". " + text + CharsEscaped + NewLine + indentation + number + ". " + text + NewLine;
            MOrderedItem item     = OrderedItem(number, text + Chars, OrderedItem(number, text));

            mw.Write(item);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #13
0
        public static void MarkdownWriter_Write_Link_NoTitle()
        {
            MarkdownWriter mw = CreateWriter();

            const string text = "LinkText";
            const string url  = "LinkUrl";

            MLink link = Link(text + Chars, url + CharsWithoutSpaces);

            string expected = $"[{text + CharsSquareBracketsBacktickLessThanEscaped}]({url + CharsWithoutSpacesParenthesesEscaped})";

            mw.Write(link);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #14
0
        public static void MarkdownWriter_Write_CodeBlock_CodeBlockOptionsEmptyLineBeforeAndAfter()
        {
            MarkdownWriter mw = CreateBuilderWithCodeBlockOptions(CodeBlockOptions.EmptyLineBeforeAndAfter);

            MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText);

            mw.Write(DefaultText);
            mw.Write(block);
            mw.Write(block);
            mw.Write(DefaultText);

            Assert.Equal(
                DefaultText + NewLine2 + CodeBlockMarkdown + NewLine + CodeBlockMarkdown + NewLine + DefaultText,
                mw.ToStringAndClear());
        }
Exemple #15
0
        public static void MarkdownWriter_Write_Image_NoTitle()
        {
            MarkdownWriter mw = CreateWriter();

            const string text = "ImageText";
            const string url  = "ImageUrl";

            MImage image = Image(text + Chars, url + CharsWithoutSpaces);

            string expected = $"![{text + CharsSquareBracketsBacktickLessThanEscaped}]({url + CharsWithoutSpacesParenthesesEscaped})";

            mw.Write(image);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #16
0
        public static void MarkdownWriter_WriteHeading_EmptyLineBeforeAfter()
        {
            string         text    = HeadingText();
            const string   s       = "# " + CharsEscaped + NewLine;
            MHeading       heading = Heading(1, Chars);
            MarkdownWriter mw      = CreateBuilderWithHeadingOptions(HeadingOptions.EmptyLineBeforeAndAfter);

            mw.Write(text);
            mw.Write(heading);
            mw.Write(heading);
            mw.Write(text);

            Assert.Equal(
                text + NewLine2 + s + NewLine + s + NewLine + text,
                mw.ToStringAndClear());
        }
Exemple #17
0
        public static void MarkdownWriter_WriteImage()
        {
            MarkdownWriter mw = CreateWriter();

            const string text  = "ImageText";
            const string url   = "ImageUrl";
            const string title = "ImageTitle";

            MImage image = Image(text + Chars, url + CharsWithoutSpaces, title + Chars);

            string expected = $"![{text + CharsSquareBracketsBacktickLessThanEscaped}]" +
                              $"({url + CharsWithoutSpacesParenthesesEscaped} \"{title + CharsDoubleQuoteEscaped}\")";

            mw.WriteImage(image.Text, image.Url, image.Title);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #18
0
        public static void MarkdownWriter_WriteLink()
        {
            MarkdownWriter mw = CreateWriter();

            const string linkText  = "LinkText";
            const string linkUrl   = "LinkUrl";
            const string linkTitle = "LinkTitle";

            const string text  = linkText + Chars;
            const string url   = linkUrl + CharsWithoutSpaces;
            const string title = linkTitle + Chars;

            string expected = $"[{linkText + CharsSquareBracketsBacktickLessThanEscaped}]({linkUrl + CharsWithoutSpacesParenthesesEscaped} \"{linkTitle + CharsDoubleQuoteEscaped}\")";

            mw.WriteLink(text, url, title);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #19
0
        public static void MarkdownWriter_WriteLink_TextWithContent()
        {
            MarkdownWriter mw = CreateWriter();

            string expected = $"[**b** *i* ~~s~~ `c` {CharsSquareBracketsBacktickLessThanEscaped}](u{CharsWithoutSpacesParenthesesEscaped} \"t{CharsDoubleQuoteEscaped}\")";

            mw.WriteStartLink();
            mw.WriteBold("b");
            mw.WriteString(" ");
            mw.WriteItalic("i");
            mw.WriteString(" ");
            mw.WriteStrikethrough("s");
            mw.WriteString(" ");
            mw.WriteInlineCode("c");
            mw.WriteString(" ");
            mw.WriteString(Chars);
            mw.WriteEndLink($"u{CharsWithoutSpaces}", $"t{Chars}");

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemple #20
0
        public static void MarkdownWriter_Write_HtmlEntity(string syntax, string format, CharEntityFormat?htmlEntityFormat)
        {
            MarkdownWriter mw = CreateBuilderWithHtmlEntityFormat(htmlEntityFormat);

            char ch = CharEntityChar();

            MCharEntity charEntity = CharEntity(ch);

            mw.Write(charEntity);

            string s = ((int)ch).ToString(format, CultureInfo.InvariantCulture);

            Assert.Equal(syntax + ((int)ch).ToString(format, CultureInfo.InvariantCulture) + ";", mw.ToStringAndClear());
        }
Exemple #21
0
        public static void MarkdownWriter_WriteHeading_UnderlineH2(HeadingOptions?options)
        {
            MarkdownWriter mw = CreateBuilderWithHeadingOptions(options);

            mw.WriteHeading2(Value);

            Assert.Equal(ValueEscaped + NewLine + new string('-', ValueEscaped.Length) + NewLine, mw.ToStringAndClear());
        }