Esempio n. 1
0
 return(new MarkdownFormat(
            BoldStyle,
            ItalicStyle,
            BulletListStyle,
            OrderedListStyle,
            HeadingStyle,
            HeadingOptions,
            TableOptions,
            CodeFenceStyle,
            CodeBlockOptions,
            CharEntityFormat,
            horizontalRuleFormat));
Esempio n. 2
0
        public static BulletListStyle Modify(this BulletListStyle style)
        {
            switch (style)
            {
            case BulletListStyle.Asterisk:
                return(BulletListStyle.Plus);

            case BulletListStyle.Plus:
                return(BulletListStyle.Minus);

            case BulletListStyle.Minus:
                return(BulletListStyle.Asterisk);

            default:
                throw new ArgumentException(style.ToString(), nameof(style));
            }
        }
Esempio n. 3
0
        public MarkdownFormat(
            EmphasisStyle boldStyle           = EmphasisStyle.Asterisk,
            EmphasisStyle italicStyle         = EmphasisStyle.Asterisk,
            BulletListStyle bulletListStyle   = BulletListStyle.Asterisk,
            OrderedListStyle orderedListStyle = OrderedListStyle.Dot,
            HeadingStyle headingStyle         = HeadingStyle.NumberSign,
            HeadingOptions headingOptions     = HeadingOptions.EmptyLineBeforeAndAfter,
            TableOptions tableOptions         = TableOptions.FormatHeader
            | TableOptions.OuterDelimiter
            | TableOptions.Padding
            | TableOptions.EmptyLineBeforeAndAfter,
            CodeFenceStyle codeFenceStyle                   = CodeFenceStyle.Backtick,
            CodeBlockOptions codeBlockOptions               = CodeBlockOptions.EmptyLineBeforeAndAfter,
            CharEntityFormat charEntityFormat               = CharEntityFormat.Hexadecimal,
            HorizontalRuleFormat?horizontalRuleFormat       = null,
            AngleBracketEscapeStyle angleBracketEscapeStyle = AngleBracketEscapeStyle.Backslash)
        {
            BoldStyle        = boldStyle;
            ItalicStyle      = italicStyle;
            BulletListStyle  = bulletListStyle;
            OrderedListStyle = orderedListStyle;
            HeadingStyle     = headingStyle;
            HeadingOptions   = headingOptions;
            TableOptions     = tableOptions;
            CodeFenceStyle   = codeFenceStyle;
            CodeBlockOptions = codeBlockOptions;
            CharEntityFormat = charEntityFormat;

            if (BulletListStyle == BulletListStyle.Asterisk)
            {
                BulletItemStart = "* ";
            }
            else if (BulletListStyle == BulletListStyle.Plus)
            {
                BulletItemStart = "+ ";
            }
            else if (BulletListStyle == BulletListStyle.Minus)
            {
                BulletItemStart = "- ";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(BulletListStyle));
            }

            if (BoldStyle == EmphasisStyle.Asterisk)
            {
                BoldDelimiter = "**";
            }
            else if (BoldStyle == EmphasisStyle.Underscore)
            {
                BoldDelimiter = "__";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(BoldStyle));
            }

            if (ItalicStyle == EmphasisStyle.Asterisk)
            {
                ItalicDelimiter = "*";
            }
            else if (ItalicStyle == EmphasisStyle.Underscore)
            {
                ItalicDelimiter = "_";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(ItalicStyle));
            }

            if (OrderedListStyle == OrderedListStyle.Dot)
            {
                OrderedItemStart = ". ";
            }
            else if (OrderedListStyle == OrderedListStyle.Parenthesis)
            {
                OrderedItemStart = ") ";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(OrderedListStyle));
            }

            if (HeadingStyle == HeadingStyle.NumberSign)
            {
                HeadingStart = "#";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(HeadingStyle));
            }

            if (CodeFenceStyle == CodeFenceStyle.Backtick)
            {
                CodeFence = "```";
            }
            else if (CodeFenceStyle == CodeFenceStyle.Tilde)
            {
                CodeFence = "~~~";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(CodeFenceStyle));
            }

            if (horizontalRuleFormat != null)
            {
                Error.ThrowOnInvalidHorizontalRuleFormat(horizontalRuleFormat.Value);

                HorizontalRuleFormat = horizontalRuleFormat.Value;
            }
            else
            {
                HorizontalRuleFormat = HorizontalRuleFormat.Default;
            }

            if (HorizontalRuleStyle == HorizontalRuleStyle.Hyphen)
            {
                HorizontalRuleText = "-";
            }
            else if (HorizontalRuleStyle == HorizontalRuleStyle.Underscore)
            {
                HorizontalRuleText = "_";
            }
            else if (HorizontalRuleStyle == HorizontalRuleStyle.Asterisk)
            {
                HorizontalRuleText = "*";
            }
            else
            {
                throw new InvalidOperationException(ErrorMessages.UnknownEnumValue(HorizontalRuleStyle));
            }

            AngleBracketEscapeStyle = angleBracketEscapeStyle;
        }
Esempio n. 4
0
        public static void MarkdownFormat_Constructor_ListItemStyle(BulletListStyle listItemStyle)
        {
            var format = new MarkdownFormat(bulletListStyle: listItemStyle);

            Assert.Equal(listItemStyle, format.BulletListStyle);
        }
Esempio n. 5
0
 public MarkdownFormat WithBulletListStyle(BulletListStyle bulletListStyle);
Esempio n. 6
0
 public MarkdownFormat(EmphasisStyle boldStyle = EmphasisStyle.Asterisk, EmphasisStyle italicStyle = EmphasisStyle.Asterisk, BulletListStyle bulletListStyle = BulletListStyle.Asterisk, OrderedListStyle orderedListStyle = OrderedListStyle.Dot, HeadingStyle headingStyle = HeadingStyle.NumberSign, HeadingOptions headingOptions = HeadingOptions.EmptyLineBeforeAndAfter, TableOptions tableOptions = TableOptions.FormatHeader | TableOptions.Padding | TableOptions.OuterDelimiter | TableOptions.EmptyLineBeforeAndAfter, CodeFenceStyle codeFenceStyle = CodeFenceStyle.Backtick, CodeBlockOptions codeBlockOptions = CodeBlockOptions.EmptyLineBeforeAndAfter, CharEntityFormat charEntityFormat = CharEntityFormat.Hexadecimal, HorizontalRuleFormat?horizontalRuleFormat = null);