anthv123 anthv123 - 1 year ago 262
Markdown Question

MarkdownSharp does not transform list

The following string will properly be transformed from a markdown list to an HTML list:

string list = "* Item1\n* Item 2";

However, if I have some other string, then append the list to it, the output is unexpected.

string text = "here is some **bold** text " + list;


here is some <b>bold</b> text * Item1 * Item 2

It seems the problem is trying to transform a list that exists in a block of other text? If that is the problem, is that the intended behavior?

Answer Source

I'm not familiar with MarkdownSharp, but most Markdown parsers expect two linebreaks (\n) between a paragraph and another paragraph, or new content.

So, by appending the list, you remove Item1 from potentially starting a new list. By only being a single linebreak (\n), MarkdownSharp is most likely not perceiving the content as the start of anything new (just a stray linebreak).

Try concatenating the list with \n\n.

string text = "here is some **bold** text\n\n" + list;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download