4

I'm trying to support syntax highlighting in the cms Plone.

The context: we are using a base Plone install. Add a document and change type from HTML to Restructuredtext then add a simple code block:

.. code-block :: python

from plone import api

Save the document and you have the following html code block

<pre class="code python literal-block">
    <span class="keyword namespace">from</span> <span class="name namespace">plone</span> <span class="keyword namespace">import</span> <span class="name">api</span>
</pre>

So the transforms happens but the classes uses here doesn't fit with any CSS I have found on Internet.

debugging this show me docutils.utils.code_analyser.py Lexer.init is called with tokennames='long' instead of tokennames='short'

This is why the class names are long. I have two options:

  • finding how to change it ? (without just monkey patching but the call chain is so big...)
  • finding how to generate with pygments the long version
toutpt
  • 5,145
  • 5
  • 38
  • 45

0 Answers0