Skip to content

Fix a case where content under admonitions weren't dettabbed properly #1102

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

Merged

Conversation

facelessuser
Copy link
Collaborator

@facelessuser facelessuser commented Feb 5, 2021

Admonitions would not render the following case properly:

!!! note "Admonition"
    - Parent 1

        - Child 1
        - Child 2

But would render this properly:

!!! note "Admontion"
    - Parent 1
        - Child 1
        - Child 2

The problem stemmed from bad detabbing of the content, where in the first example, the child list was parsed like this:

  - Child 1
      - Child 2

This pull addresses the issue of ensuring that each block is processed properly so that content that is highly sensitive to indentation works correctly.

@facelessuser facelessuser force-pushed the bugfix/admonition-detab branch from 1f282c6 to b165cef Compare February 5, 2021 19:58
@facelessuser
Copy link
Collaborator Author

I'm ignoring the "checklinks" failure. I feel that should be fixed in a separate issue.

@waylan
Copy link
Member

waylan commented Feb 5, 2021

I think you have an error in your first example. As is, it renders to

<div class="admonition note">
<p class="admonition-title">Admonition</p>
</div>
<ul>
<li>
<p>Parent 1</p>
<ul>
<li>Child 1</li>
<li>Child 2</li>
</ul>
</li>
</ul>

.. which is correct, The - Parent 1 line is not indented by four spaces and is therefore not a child of the admonition. Therefore it gets parsed as a list outside of the admonition as it should.

However, if you use proper indentation, like this:

!!! note "Admonition"
    - Parent 1

        - Child 1
        - Child 2

Then we get the rather strange output:

<div class="admonition note">
<p class="admonition-title">Admonition</p>
<ul>
<li>
<p>Parent 1</p>
<ul>
<li>Child 1<ul>
<li>Child 2</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

And yes that is a bug which needs fixing. So, thank you.

@facelessuser
Copy link
Collaborator Author

Sorry, that was a formatting issue for the comment, not the actual test or failure.

@facelessuser
Copy link
Collaborator Author

I've corrected the comment in the pull, but the issue is valid.

@waylan waylan merged commit 0e6dc4c into Python-Markdown:master Feb 5, 2021
mitya57 added a commit to mitya57/markdown that referenced this pull request Aug 11, 2021
PR Python-Markdown#1102 was included in 3.3.4, not 3.3.0.

Also fix a typo in another changelog entry.
waylan pushed a commit that referenced this pull request Aug 11, 2021
PR #1102 was included in 3.3.4, not 3.3.0.

Also fix a typo in another changelog entry.
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