hey-red / Markdown

Open source C# implementation of Markdown processor, as featured on Stack Overflow.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_emptyElementSuffix null when passing empty MarkdownOptions

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1. Call public Markdown(MarkdownOptions options)
2. Transform text that generates empty html element (eg. <br />)
3. Inspect invalid html

What is the expected output? What do you see instead?
Expect html with '<br />', seeing '<br'

Please provide any additional information below.

This unit-test demonstrated the problem:
        [Test]
        public void BreaklinesWithEmptyOptions()
        {
            string input = "Bla bla:  \r\nFoo";
            string expected = "Bla bla:<br />\nAppHarbor Inc.";
            var markdownSharp = new Markdown(
                new MarkdownOptions{}
            );
            string actual = markdownSharp.Transform(input);
            Assert.AreEqual(expected, actual);
        }

It's due to bad option handling. Supposedly, emptyelementsuffix id initialized 
to a sane default in this line:
private string _emptyElementSuffix = " />";

But that gets overriden with 'null' if one foolishly passes an options-object 
without setting 'EmptyElementSuffix'

Original issue reported on code.google.com by fri...@gmail.com on 27 Jan 2011 at 1:29

  • Merged into: #38
Whoops, this is actually a dupe of Issue 38: 
http://code.google.com/p/markdownsharp/issues/detail?id=38

Original comment by fri...@gmail.com on 27 Jan 2011 at 4:33

Original comment by wump...@gmail.com on 28 Feb 2011 at 5:03

  • Changed state: Duplicate