lruiz/MarkdownPapers

Code block within a list item

amroamroamro opened this issue · 5 comments

According to Markdown syntax, it should be possible to include code blocks within a list item as follows:

This is a list:

* first item, with some code:

        int x = 10;

* second item

Thank you

(Note that the code block is indented twice with 8 spaces as required)

The output from this parser is:

<p>This is a list:</p>
<ul>
<li>
<p>first item, with some code:</p>
<p>        int x = 10;</p>
</li>
<li><p>second item</p></li>
</ul>
<p>Thank you</p>

However, the expected output should be:

<p>This is a list:</p>
<ul>
<li>
<p>first item, with some code:</p>
<pre><code>int x = 10;</code></pre>
</li>
<li><p>second item</p></li>
</ul>
<p>Thank you</p>

Tested on MarkdownPapers v1.2.3 and v1.3.3, Java 1.6.0.41

thank you for the fix.

I pulled the latest 1.3.4 version, and tried again the same example above. While the code block is properly rendered using a pre/code tags, however there is an extra 4 spaces at the beginning of the code section (inside <pre>):

<p>This is a list:</p>
<ul>
<li>
<p>first item, with some code:</p>
<pre><code>    int x = 10;</code></pre>
</li>
<li><p>second item</p></li>
</ul>
<p>Thank you</p>

The double indentation is part of the markdown syntax to mark code blocks within lists, so no leading spaces should show up in the output HTML (only those beyond the 8 spaces must).

thanks again for looking into this.

I will look into this, before releasing it.

Thank you for reporting.

Done!!!, fixed he extra 4 spaces.

great, much appreciated! The code section is properly indented now.

This is not high priority, but I was wondering how the code behaves when there are more than 8 spaces. So I took the liberty of comparing the output with other Markdown parsers accessible online:

Using 9 spaces, it seems that the majority of parsers maintain the extra space in the pre/code block (really anything beyond the required eight), although there are a few instances that truncate them like this project.

Now I'm not sure which one is part of the standard, I just thought I should mention it here...

Anyway thank you for fixing the main bug.

👍 awesome, thank you for the quick fix