Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markup for fenced code with linenos #1746

Merged
merged 2 commits into from
Jan 28, 2022

Conversation

mwcz
Copy link
Contributor

@mwcz mwcz commented Jan 26, 2022

fixes #1743

The fix adds some missing </td> and </tr> tags in the linenos tables. Some closing tags can be inferred by the browser, which is why this works without minify_html, but I think it's best if Zola generates "normal" HTML and relies on minify_html to remove unnecessary tags. Passing already-partially-minified HTML to minify seems to be causing this problem.

Though, since the HTML is technically valid already, minify-html may deserve a patch to support it, but that's not something I have the energy for at the moment!

IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.

The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?
    • No documentation changes required

@mwcz
Copy link
Contributor Author

mwcz commented Jan 27, 2022

I'll try to take a look at the test failures tomorrow.

@mwcz
Copy link
Contributor Author

mwcz commented Jan 27, 2022

Eh, how about tonight instead. :) Just pushed a fix for the tests that involve fenced code and linenos.

The test changes might be hard to scan visually due to the HTML being so dense. They all boil down to adding omitted </td> and </tr> where they should be. For example, here's the HTML string for is_highlighting_linenos_still_working, formatted, with comments added for where the missing tags are added in this PR.

<pre data-linenos data-lang="html" style="background-color:#2b303b;color:#c0c5ce;" class="language-html ">
    <code class="language-html" data-lang="html">
        <table>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>
                        <span>&lt;</span>
                        <span style="color:#bf616a;">div </span>
                        <span style="color:#8fa1b3;">id</span>
                        <span>=&quot;</span>
                        <span style="color:#a3be8c;">custom-attr</span>
                        <span>&quot;&gt;\n</span>
                    <!-- missing </td> -->
                <!-- missing </tr> -->
                <tr>
                    <td>2</td>
                    <td>
                        <span>&lt;</span>
                        <span style="color:#bf616a;">div </span>
                        <span>&gt;\n</span>
                    <!-- missing </td> -->
                <!-- missing </tr> -->
                <tr>
                    <td>3</td>
                    <td>
                        <span>    &lt;</span>
                        <span style="color:#bf616a;">iframe </span>
                        <span style="color:#d08770;">src</span>
                        <span>=&quot;</span>
                        <span style="color:#a3be8c;">https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ</span>
                        <span>&quot; </span>
                        <span style="color:#d08770;">webkitallowfullscreen mozallowfullscreen allowfullscreen</span>
                        <span>&gt;&lt;/</span>
                        <span style="color:#bf616a;">iframe</span>
                        <span>&gt;\n</span>
                    <!-- missing </td> -->
                <!-- missing </tr> -->
                <tr>
                    <td>4</td>
                    <td>
                        <span>&lt;/</span>
                        <span style="color:#bf616a;">div</span>
                        <span>&gt;\n</span>
                    <!-- missing </td> -->
                <!-- missing </tr> -->
                <tr>
                    <td>5</td>
                    <td>
                        <span>\n</span>
                    <!-- missing </td> -->
                <!-- missing </tr> -->
                <tr>
                    <td>6</td>
                    <td>
                        <span>&lt;/</span>
                        <span style="color:#bf616a;">div</span>
                        <span>&gt;\n</span>
                    <!-- missing </td> -->
                </tr>
            </tbody>
        </table>
    </code>
</pre>

Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I'm planning to switch all those tests to insta which will be much nicer I guess.

@Keats Keats merged commit afbccec into getzola:next Jan 28, 2022
@mwcz mwcz deleted the fix-fenced-code-with-linenos branch January 28, 2022 18:15
Keats pushed a commit that referenced this pull request Feb 14, 2022
* fix fenced code blocks with linenos and minify_html

* fix test cases involving linenos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants