Reputation: 2730
I'm trying to create a list in Markdown. As I've read in some documentation, if I write this Markdown code:
My list
* first item
* second item
* third item
Not in the list
I would get as result the same as if I write this in HTML:
<p>My list</p>
<li>
<ul>first item</ul>
<ul>second item</ul>
<ul>third item</ul>
</li>
<p>Not in the list</p>
I use Atom as editor and its Markdown previewer and everything is OK, but when I use pandoc
to convert my Markdown file as follows:
pandoc test.md -o test.odt
what I get is this:
My list * first item * second item * third item
Not in the list
Where am I doing wrong?
Upvotes: 9
Views: 7379
Reputation: 42627
There are two possible solutions to your problem:
Add a blank line between the paragraph and the list (as @melpomene mentioned in a comment).
My list
* first item
* second item
* third item
Not in the list
Leave out the blank line and tell Pandoc to use commonmark
as the input format rather than the default, markdown
.
pandoc -f commonmark -o test.odt test.md
The "problem" is that the Atom editor uses a CommonMark parser and, by default, Pandoc uses an old-school Markdown parser which mostly follows these rules and the reference implementation (markdown.pl
). In fact, the Commonmark spec specifically acknowledges this difference:
In CommonMark, a list can interrupt a paragraph. That is, no blank line is needed to separate a paragraph from a following list:
Foo - bar - baz <p>Foo</p> <ul> <li>bar</li> <li>baz</li> </ul>
Markdown.pl
does not allow this, through fear of triggering a list via a numeral in a hard-wrapped line:The number of windows in my house is 14. The number of doors is 6.
If you want common behavior among your tools, then you need to only use tools which follow the same behavior.
Upvotes: 13