Beispiel #1
0
        /// <summary>
        /// Generates the "values" section; this contains tables describing all of the JSON types.
        /// </summary>
        private void WriteValuesSection()
        {
            _writer.WriteLine(new Header(2, "Values"));
            _writer.Write(new Paragraph("The following tables describe the values you need to set in the schema."));

            foreach (var resDefName in _schema.ResourceDefinitions.Keys)
            {
                var resDef = _schema.ResourceDefinitions[resDefName];
                Debug.Assert(resDef.JsonType == "object");
                var table = CreateTable(resDefName, resDef);
                _writer.Write(table);
            }

            foreach (var defName in _schema.Definitions.Keys)
            {
                var def = _schema.Definitions[defName];

                // there are a handful of objects with null properties because the properties
                // are all read-only.  for now just skip them to avoid a crash during table creation.
                if (def.Properties == null)
                {
                    continue;
                }

                var table = CreateTable(defName, def);
                _writer.Write(table);
            }
        }
        public static void MFactory_HorizontalRule_Throws(int count)
        {
            MarkdownWriter mb = CreateWriter();

            Assert.Throws <ArgumentOutOfRangeException>(() => mb.Write(MFactory.HorizontalRule(style: HorizontalRuleStyle.Asterisk, count: count, separator: " ")));
            Assert.Throws <ArgumentOutOfRangeException>(() => mb.Write(MFactory.HorizontalRule(style: HorizontalRuleStyle.Hyphen, count: count, separator: " ")));
            Assert.Throws <ArgumentOutOfRangeException>(() => mb.Write(MFactory.HorizontalRule(style: HorizontalRuleStyle.Underscore, count: count, separator: " ")));
        }
        /// <summary>
        /// Generates the "values" section; this contains tables describing all of the JSON types.
        /// </summary>
        private void WriteValuesSection(JsonSchema schema)
        {
            _writer.WriteLine(new Header(2, "Property values"));
            _writer.Write(new Paragraph("The following tables describe the values you need to set in the schema."));

            var table = CreateTables(schema.Description, schema);

            _writer.Write(table);
        }
Beispiel #4
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());
        }
        public override void WriteTo(MarkdownWriter writer)
        {
            if (content is string s)
            {
                writer.WriteTaskItem(s);
            }
            else
            {
                foreach (MElement element in Elements())
                {
                    writer.WriteStartTaskItem();

                    if (element is MTaskItem item)
                    {
                        item.WriteContentTo(writer);
                    }
                    else
                    {
                        writer.Write(element);
                    }

                    writer.WriteEndTaskItem();
                }

                writer.WriteLine();
            }
        }
Beispiel #6
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());
        }
        public override void WriteTo(MarkdownWriter writer)
        {
            if (content is string s)
            {
                writer.WriteOrderedItem(NumberingBase, s);
            }
            else
            {
                int number = NumberingBase;

                foreach (MElement element in Elements())
                {
                    writer.WriteStartOrderedItem(number);

                    if (element is MOrderedItem item)
                    {
                        item.WriteContentTo(writer);
                    }
                    else
                    {
                        writer.Write(element);
                    }

                    writer.WriteEndOrderedItem();
                    number++;
                }

                writer.WriteLine();
            }
        }
Beispiel #8
0
        public static void MarkdownWriter_Write_BlockQuote(string text1, string text2)
        {
            MarkdownWriter mw         = CreateWriter();
            MBlockQuote    blockQuote = BlockQuote(text1);

            mw.Write(blockQuote);

            Assert.Equal(text2, mw.ToStringAndClear());
        }
Beispiel #9
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());
        }
Beispiel #10
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());
        }
Beispiel #11
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());
        }
Beispiel #12
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());
        }
Beispiel #13
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);

            Assert.Equal(syntax + ((int)ch).ToString(format, CultureInfo.InvariantCulture) + ";", mw.ToStringAndClear());
        }
Beispiel #14
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());
        }
Beispiel #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());
        }
Beispiel #16
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());
        }
        public static MarkdownWriter Write2(this MarkdownWriter writer, object value)
        {
            writer.Write(value);

            return(writer);
        }