Skip to content

Invalid highlight html with rouge and linenos #2607

@kostrse

Description

@kostrse

Invalid HTML generated when highlighter set to rouge and highlight has option linenos.

For kramdown and redcarpet html is slightly different, but in both cases invalid.

Original markdown:

before

{% highlight cs linenos %}
abc
def
{% endhighlight %}

after

Resulting html for redcarpet:

<p>before</p>
<div class="highlight">
    <pre>
        <code class="language-cs" data-lang="cs">
            <table style="border-spacing: 0">
                <tbody>
                    <tr>
                        <td class="gutter gl" style="text-align: right">
                            <pre class="lineno">
                                1
                                2
        </code>
                            </pre>
                        </td>
                        <td class="code">
                            <pre>
                                <span class="n">abc</span>
                                <span class="n">def</span>
                                <span class="w"></span>
                            </pre>
                        </td>
                    </tr>
                </tbody>
            </table>
    </pre>
</div>
<p>after</p>

Problem: code closed inside the table.

Resulting html for kramdown:

<p>before</p>
<div class="highlight">
    <pre>
        <code class="language-cs" data-lang="cs">
            <table style="border-spacing: 0">
                <tbody>
                    <tr>
                        <td class="gutter gl" style="text-align: right">
                            <pre class="lineno">
                            1
                            2
                            </pre>
                        </td>
                        <td class="code">
                            <pre>
                                <span class="n">abc</span>
                                <span class="n">def</span>
                                <span class="w"></span>
                            </pre>
                        </td>
                    </tr>
                </tbody>
            </table>
            after
        </code>
    </pre>
</div>

Problem: "after" inside highlighter div block, should be inside p after the block.

Reproduced with:

jekyll 2.1.1 and 2.2.0 (@phocks)
rouge 1.5.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions