Skip to content

Code listings with include: directive are not colorized #8

Open

Description

@ptitmain

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:

  • code-block => short names => colors ok
  • include => long name => colors not ok

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.

Activity

  1. changed the title [-]Code listings include with include: directive are not colorized[/-] [+]Code listings with include: directive are not colorized[/+] on Jan 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions