What is the correct way of creating a HTML code snippet with pygments
/ python-markdown
/ django-markdownx
? Basically, I am trying to make it look like the code blocks in the official Python documentation: https://docs.python.org/3/library/csv.html
Example: I am trying to convert the following piece:
>>> s = "Hello World!"
>>> print(s[0])
H
By using the back tics in Markdown (normally not indented, fix for posting here):
```python
>>> s = "Hello World!"
>>> print(s[0])
H
```
The result from python-markdown
is as follows:
<div class="codehilite">
<pre>
<span></span>
<code>
<span class="o">>>></span>
<span class="n">s</span>
<span class="o">=</span>
<span class="s2">"Hello World!"</span>
<span class="o">>>></span>
<span class="nb">print</span>
<span class="p">(</span>
<span class="n">s</span>
<span class="p">[</span>
<span class="mi">0</span>
<span class="p">])</span>
<span class="n">H</span>
</code>
</pre>
</div>
Which is almost what I need. Except, I would like to have the >>>
as class=gp
and the result H
as class=go
:
<span class="gp">>>></span>
<span class="go">H</span>
It has probably something to do with how to write the input, but I cannot figure it out how to do it. Any help is very much appreciated!