Задать вопрос

Тел: +7 965 3737 888

462

Просмотров

1

Ответов

Another pygments for ReST

<p>This is like <a href="https://djangosnippets.org/snippets/36/">snippet 36</a>. And it'll return css also. And it's not a filter.If the code parameter is skip, it'll test the code first, and if there is not a suiable lexer for the code, then use default python lexer to render the code. The code lanauage parameter is comes from pygments lexer alias.</p>
<h2>How to use it</h2>
<p>html = to_html(rest_text)</p>
<p>And there is a level parameter in to_html function, default is 2, it's the sections level. And the html will be css style + body</p>
<h2>How to write ReST</h2>
<p>Below is a example.</p>
This is a test.

.. code::

   def code(name, arguments, options, content, lineno,
             content_offset, block_text, state, state_machine):
       opt = {'display':'on'}
       opt.update(options)

       docnodes.Node(content, ''.join(arguments), **opt)
       if opt['display'].lower() == 'on':
           return [nodes.literal_block('', '\n'.join(content))]
       else:
           return []

.. code:: html+django

   &lt;h1 id="title"&gt;&#36890;&#35759;&#24405;&lt;/h1&gt;
   &lt;hr&gt;
   &lt;div&gt;
   &lt;table border="0" width="500"&gt;
   &lt;tr align="right"&gt;
     &lt;td&gt;{% if has_previous %}
       &lt;a href="/address?page={{ previous }}"&gt;&#19978;&#19968;&#39029;&lt;/a&gt;
       {% endif %} {% if has_next %}
       &lt;a href="/address?page={{ next }}"&gt;&#19979;&#19968;&#39029;&lt;/a&gt;
       {% endif %}&lt;/td&gt;&lt;/tr&gt;
   &lt;/table&gt;

Вопрос полезен? Да0/Нет0
file_5127.py(2.4Кб)
None

Ответы (1):

Ответlimodou:27.02.2007
Ответ полезен? Да0/Нет0

ok, I see.