bobtfish / text-markdown

The perl Text::Markdown CPAN module
Other
50 stars 21 forks source link

Lists + verbatim code blocks with indentation get nested <pre> tags #20

Open etherealvisage opened 12 years ago

etherealvisage commented 12 years ago

Hello,

I've found (the hard way) an input case that seems to break the Text::Markdown handling of verbatim blocks. I'm using Text::Markdown 1.000031 (latest from CPAN) with Perl 5.16.0 on x86_64.

Here's what happens to a simple illustrative test:

For illustration purposes:                                                      

    Pre block                                                                      
    More pre content                                                               
        Indented region                                                            

        Indented, with blank line between

The output becomes (as expected):

<p>For illustration purposes:</p>

<pre><code>Pre block
More pre content
    Indented region

    Indented, with blank line between
</code></pre>

Now, for the bug. Wrapping the original in a list with a hanging indent gives for input:

1. List item                                                                       
    Continued text from previous region.                                           

        Pre block                                                                  
        More pre content . . .                                                     
            Indented region                                                        

                Indented, with blank line between

But the output is inconsistent with the previous:

<ol>
<li><p>List item
Continued text from previous region.</p>

<pre><code>Pre block
More pre content . . .
    Indented region

<pre><code>Indented, with blank line between
</code></pre>

</code></pre></li>
</ol>

Note the nested <pre> and <code> tags. This doesn't seem correct to me, but please feel free to convince me otherwise. It also seems to happen without the hanging indent on the list item, for reference.

I've done a bit of digging around in the Text::Markdown source, but I haven't found anything that looks like it would cause this yet. Then again, I'm still learning Perl, and hence it is entirely conceivable that I'm missing something. If someone else could take a look at this and reproduce/fix, it would be appreciated!

Thanks.