ionelmc / python-darkslide

Generate HTML5 slideshows from markdown, ReST, or textile
http://ionelmc.github.io/python-darkslide/
Apache License 2.0
97 stars 22 forks source link

Code listings with include: directive are not colorized #8

Open ptitmain opened 6 years ago

ptitmain commented 6 years ago

Hello This is an old bug already present in landslide. Included a code with the include directive generates a block of code with full name of css classes instead a short names when using the code-block directive. Thus:

For example:

Test
====

.. include:: test.js
   :code: javascript

.. code-block:: javascript

   const http = require('http');

Generates:

<section><pre class="code javascript literal-block">
<span class="keyword reserved">const</span> <span class="name other">http</span> <span class="operator">=</span> <span class="name other">require</span><span class="punctuation">(</span><span class="literal string single">'http'</span><span class="punctuation">);</span>
</pre>
<pre><span></span><span class="kr">const</span> <span class="nx">http</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;http&#39;</span><span class="p">);</span>
</pre></section>

The "kr" class is present in the default pygment CSS but not "keyword reserved".

A workaround is to duplicate the CSS pygment and replace each short name by a long one (or to find somewhere the default CSS in long names but I cannot find it online).

A fix would be to ask pygment to generate short names for the include directive. But maybe this is done somewhere in the docutils framework and is cannot be controlled from darkslide. I found this bug that seems to explain how to push parameters to the Html formatter object but I cannot find how to do this in the code of darkslide.