trentm/python-markdown2

Fenced-code-blocks extra funky movments

Lucksinia opened this issue · 1 comments

Describe the bug
Code block don't get wrapped in <pre></pre> tags, but gets wrapped only in <code></code> tags instead.
It don't highlites it at all, but that's a little different.

To Reproduce

while using html = markdown2.markdown(str(path_to_test.open().read()), use_file_vars=True)
where path_to_test is a Path() object
Something like this:

```python
import markdown2
html = markdown2.markdown(test_post, extras["use-file-vars"])
```

is translated to:

<p><code> python
import markdown2
html = markdown2.markdown(test_post, extras["use-file-vars"])
</code></p>

Expected behavior
Something like this:

<p>
<pre><code lang="python">
import markdown2
html = markdown2.markdown(test_post, extras["use-file-vars"])
</code></pre></p>

Or without lang attribute, as I can see from tests in the repo.
Debug info
Version of library being used: 2.4.11 markdown2[all]

Any extras being used: use-file-vars with this in markdown:
-*- markdown-extras: code-friendly, footnotes, metadata, nofollow, strike, tag-friendly, spoiler, fenced-code-blocks -*-

Additional context
I don't know how this works, so it may clash with metadata string before the file vars... Or not. I am in shambles.

Okay, That was not markdown per say, but something in Pygments... I reinstalled it again, and now it properly tokenizes things.
Closing the issue, because that was my broken version of Pygments. (and not knowing what exactly I would get at the end.)

...For anyone who is curious and don't know what I'm talking about, those lines actually should look something like this:

<div class="codehilite">
    <pre><span></span><code><span class="kn">import</span> <span class="nn">markdown2</span>
<span class="n">html</span> <span class="o">=</span> <span class="n">markdown2</span><span class="o">.</span><span class="n">markdown</span><span class="p">(</span><span class="n">test_post</span><span class="p">,</span> <span class="n">extras</span><span class="p">[</span><span class="s2">&quot;use-file-vars&quot;</span><span class="p">])</span>
</code></pre>
  </div>

and after applying correct .css with all those classes, you can get something like that:

This is not the standard css configuration, for the standart one, you should refer to Pygments docs.

image