Esempio n. 1
0
        public void DeepEquals_returns_expected_value()
        {
            var instance1 = new MdThematicBreak();

            Assert.True(instance1.DeepEquals(instance1));
            Assert.True(instance1.DeepEquals(new MdThematicBreak()));

            Assert.False(instance1.DeepEquals(null));
            Assert.False(instance1.DeepEquals(new MdParagraph()));
        }
Esempio n. 2
0
        public void Visit(MdThematicBreak thematicBreak)
        {
            var style = m_Options.ThematicBreakStyle;

            // if a thematic break occurs inside a bullet list
            // and the configured style of the list and the thematic break are configured the same
            // the thematic break takes precedence and hence the list is rendered incorrectly
            // (s. https://spec.commonmark.org/0.28/#thematic-breaks)
            // To avoid this conflict, check for this scenario and change the style
            // of the thematic break if necessary
            if (m_BulletListLevel > 0)
            {
                if ((style == MdThematicBreakStyle.Dash && m_Options.BulletListStyle == MdBulletListStyle.Dash)
                    ||
                    (style == MdThematicBreakStyle.Asterisk && m_Options.BulletListStyle == MdBulletListStyle.Asterisk))
                {
                    style = MdThematicBreakStyle.Underscore;
                }
            }

            switch (style)
            {
            case MdThematicBreakStyle.Dash:
                m_Writer.WriteLine("---");
                break;

            case MdThematicBreakStyle.Asterisk:
                m_Writer.WriteLine("***");
                break;

            case MdThematicBreakStyle.Underscore:
                m_Writer.WriteLine("___");
                break;

            default:
                throw new ArgumentException($"Unsupported thematic break style: {m_Options.ThematicBreakStyle}");
            }
        }