Skip to content

Admonition inserts a codehilite div when there are more than 12 spaces after the title #550

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

Closed
pavelanni opened this issue Mar 4, 2017 · 3 comments
Labels
bug Bug report.

Comments

@pavelanni
Copy link

I'm using MkDocs with Python Markdown. I noticed this strange bug:

Expected behavior

When I insert !!! tip "Tip title" or !!! note "Note title" I expect it to create <div class="admonition tip"> then <div class="admonition-title"> and then a normal paragraph.

Actual behavior

When in my .md file the string !!! tip "Tip title" has more than 12 spaces after the title (till the end of the line) it creates an additional div after the title and before the paragraph: <div class="codehilite">. On the screen it looks like a grey strip one-line high.

It's not a big deal, especially after I figured it out and especially if you make white spaces visible in the editor. But it might surprise somebody.

Steps to reproduce the bug

  1. In the .md file enter !!! tip "Tip title"
    Make sure there are more than 12 spaces after the title
  2. Run mkdocs serve
  3. Inspect element in the admonition: see the added <div class="codehilite">. On the screen it looks like a grey strip one-line high.
  4. Remove spaces to make their number 12 or less, check that it disappears.

Package versions

  • Python: python --version
    Python 3.5.2
  • MkDocs: mkdocs --version
    mkdocs, version 0.16.1
  • Material: pip show mkdocs-material | grep -E ^Version
    Version: 1.2.0

Project configuration

theme: 'material'
markdown_extensions:
  - admonition
  - codehilite
  - pymdownx.arithmatex
  - pymdownx.betterem(smart_enable=all)
  - pymdownx.caret
  - pymdownx.critic
  - pymdownx.inlinehilite
  - pymdownx.magiclink
  - pymdownx.mark
  - pymdownx.smartsymbols
  - pymdownx.superfences
  - pymdownx.tasklist(custom_checkbox=true)
  - pymdownx.tilde

System information

  • OS: [The operating system you're running]
    Fedora Linux 25
  • Browser: [The browser used, if relevant]
    Mozilla Firefox
@waylan
Copy link
Member

waylan commented Mar 5, 2017

Thank you for the report. Actually it appears that 13 spaces are needed. Here's the simplest input to reproduce:

>>> markdown.markdown('!!! note             ', extensions=['admonition'])
u'<div class="admonition note">\n<p class="admonition-title">Note<pre><code>\n</code></pre>\n</p>\n</div>'

@waylan waylan added the bug Bug report. label Mar 5, 2017
@facelessuser
Copy link
Collaborator

Most likey the trailing whitespace is being treated as a sperate line. It may be best to just include the trailing whitespace in the admonition header regex, and then just throw it away.

@waylan waylan closed this as completed in fd4d1d2 Mar 5, 2017
@waylan
Copy link
Member

waylan commented Mar 5, 2017

@facelessuser you are absolutely right. Not sure why whitespace was so strict in that regex. I even had to account for the newline later. Anyway, its fixed now.

WhiteWinterWolf added a commit to WhiteWinterWolf/markdown that referenced this issue Sep 8, 2017
Updated the regex to include the fix from the issue Python-Markdown#550.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report.
Projects
None yet
Development

No branches or pull requests

3 participants