Пример #1
0
        public static HeadingStyle Modify(this HeadingStyle style)
        {
            switch (style)
            {
            case HeadingStyle.NumberSign:
                return(HeadingStyle.NumberSign);

            default:
                throw new ArgumentException(style.ToString(), nameof(style));
            }
        }
Пример #2
0
 return(new MarkdownFormat(
            BoldStyle,
            ItalicStyle,
            BulletListStyle,
            OrderedListStyle,
            HeadingStyle,
            HeadingOptions,
            TableOptions,
            CodeFenceStyle,
            CodeBlockOptions,
            CharEntityFormat,
            horizontalRuleFormat));
Пример #3
0
        // https://stackoverflow.com/a/7490772/1720761
        /// <summary>
        /// Returns a textual representation of the heading.
        ///
        /// This representation has a maximum deviation of 11.25 degrees.
        /// </summary>
        /// <returns>A textual representation of the heading</returns>
        /// <param name="heading">The heading value</param>
        /// <param name="culture">The culture to return the textual representation in</param>
        /// <param name="style">Whether to return a short result or not. <see cref="HeadingStyle"/></param>
        public static string ToHeading(this double heading, HeadingStyle style = HeadingStyle.Abbreviated, CultureInfo culture = null)
        {
            var val = (int)((heading / 22.5) + .5);

            var result = headings[val % 16];

            if (style == HeadingStyle.Abbreviated)
            {
                return(Resources.GetResource($"{result}_Short", culture));
            }

            result = Resources.GetResource(result, culture);
            return(result);
        }
Пример #4
0
        [Test] //TODO: make this useful with assertions
        public void TestBasicHeadingStyle()
        {
            IDocument    myDoc        = new Document2004();
            Heading1     h1           = new Heading1("Heading 111");
            HeadingStyle headingStyle = new HeadingStyle();

            headingStyle.Align(Align.CENTER);
            headingStyle.Italic();

            h1.Style = headingStyle;
            myDoc.Body.AddEle(h1);

            myDoc.Body.AddEle(new Heading2("Heading 222"));
            myDoc.Body.AddEle(new Heading3("Heading 333"));
        }
Пример #5
0
        public void SanityTest()
        {
            Heading1 heading1 = new Heading1("h111");

            Assert.AreEqual(1, TestUtils.RegexCount(heading1.Template, "<w:p wsp:rsidR*"));
            Assert.AreEqual(1, TestUtils.RegexCount(heading1.Template, "<w:t>[{]value[}]</w:t>"));
            //it has to have the pace holder
            Assert.AreEqual(1, TestUtils.RegexCount(heading1.Template, "</w:p>"));
            Assert.AreEqual(1, TestUtils.RegexCount(heading1.Template, "<w:pStyle w:val=\"Heading1\" />"));
            // it has to replace the Type of Heading

            Assert.NotNull(heading1.Style);
            HeadingStyle style = new HeadingStyle();

            heading1.Style = style;
            Assert.NotNull(heading1.Style);
        }
Пример #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.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;
        }
Пример #7
0
        public static void MarkdownFormat_Constructor_HeadingStyle(HeadingStyle headingStyle)
        {
            var format = new MarkdownFormat(headingStyle: headingStyle);

            Assert.Equal(headingStyle, format.HeadingStyle);
        }
Пример #8
0
 public MarkdownFormat WithHeadingOptions(HeadingStyle headingStyle);
Пример #9
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);