Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I could make it work as follows :</p> <ol> <li><p>To generate <code>&lt;pre&gt;..&lt;/pre&gt;</code>, I needed to modify ParsedLiteral, so I copied the ParsedLiteral class into Code as follows. Changing the line 5 <code>self.options['class'] = ['brush: js;'] # &lt;--</code> is the main idea.</p> <p>class Code(Directive):</p> <pre><code>option_spec = {'class': directives.class_option} has_content = True def run(self): self.options['class'] = ['brush: js;'] # &lt;-- set_classes(self.options) self.assert_has_content() text = '\n'.join(self.content) text_nodes, messages = self.state.inline_text(text, self.lineno) node = nodes.literal_block(text, '', *text_nodes, **self.options) node.line = self.content_offset + 1 return [node] + messages </code></pre></li> <li><p>Add one line in <strong>init</strong>.py as follows.</p> <p>_directive_registry = { 'code' : ('body', 'Code'),</p></li> </ol> <p>Now, you can use the following code</p> <pre><code>.. code:: print "Hello world!" # *tricky* code </code></pre> <p>To get this HTML code</p> <pre><code>&lt;pre class="brush: js; literal-block"&gt; print &amp;quot;Hello world!&amp;quot; # &lt;em&gt;tricky&lt;/em&gt; code &lt;/pre&gt; </code></pre> <h2>Possible Easy Solution?</h2> <p>I could use ParsedLiteral if I find a way to pass the parameter of 'bruch: js;'. However, when I tried the code</p> <pre><code>.. parsed-literal:: :class: "brunch: js;" print "Hello world!" # *tricky* code </code></pre> <p>The tag becomes <code>&lt;pre class="brunch ja"&gt;</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload