Discussion:
[Docutils-users] exclamation mark in code block generates error tag around !
Jeff Hinrichs - DM&T
2016-01-01 14:57:49 UTC
Permalink
rST:

.. code:: python
print('Hello World!')
Hello World!
generates the following HTML using rst2html.py <body> <div class="document"> <pre class="code python literal-block"> <span class="operator">&gt;&gt;&gt;</span> <span
class="keyword">print</span><span class="punctuation">(</span><span
class="literal string">'Hello World!'</span><span
class="punctuation">)</span>
<span class="name">Hello</span> <span class="name">World</span><span
class="error">!</span> <span class="operator">&gt;&gt;&gt;</span>
</pre>
</div>
</body>

NOTE: the <span class="error">!<span> I can not figure out how to escape
the exclamation point.

Any input on what I am doing wrong would be appreciated.
--
Best,

Jeff Hinrichs
402.218.1473
Jeff Hinrichs - DM&T
2016-01-01 15:11:40 UTC
Permalink
for completeness:

$ rst2html.py --version
rst2html.py (Docutils 0.12 [release], Python 3.4.3, on linux)

rst2html.py --verbose exclamation.rst exclamation.html
Post by Jeff Hinrichs - DM&T
.. code:: python
print('Hello World!')
Hello World!
class="keyword">print</span><span class="punctuation">(</span><span
class="literal string">'Hello World!'</span><span
class="punctuation">)</span>
<span class="name">Hello</span> <span class="name">World</span><span
</pre>
</div>
</body>
NOTE: the <span class="error">!<span> I can not figure out how to escape
the exclamation point.
Any input on what I am doing wrong would be appreciated.
--
Best,
Jeff Hinrichs
402.218.1473
--
Best,

Jeff Hinrichs
402.218.1473
Marc 'BlackJack' Rintsch
2016-01-01 16:15:10 UTC
Permalink
Post by Jeff Hinrichs - DM&T
.. code:: python
print('Hello World!')
Hello World!
The problem here is that you are trying to highlight code as Python
source code which is a console session and not just Python source code.

Pygments has a separate lexer for console sessions called `pycon`. Try
that one instead of `python`.

Ciao,
Marc 'BlackJack' Rintsch
--
„A life is like a garden. Perfect moments can be had, but not preserved,
except in memory. LLAP” — Leonard Nimoy's last tweet.
Jeff Hinrichs - DM&T
2016-01-01 16:37:22 UTC
Permalink
Thank you, thank you.
Post by Marc 'BlackJack' Rintsch
Post by Jeff Hinrichs - DM&T
.. code:: python
print('Hello World!')
Hello World!
The problem here is that you are trying to highlight code as Python
source code which is a console session and not just Python source code.
Pygments has a separate lexer for console sessions called `pycon`. Try
that one instead of `python`.
Ciao,
Marc 'BlackJack' Rintsch
--
„A life is like a garden. Perfect moments can be had, but not preserved,
except in memory. LLAP” — Leonard Nimoy's last tweet.
------------------------------------------------------------------------------
_______________________________________________
Docutils-users mailing list
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.
--
Best,

Jeff Hinrichs
402.218.1473
Loading...