Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using reStructuredText to add some HTML with custom "id" and "class" attributes

Using rsStructuredText to generate HTML, I am trying to wrap a

paragraph with an extra div element. The must contain an "id" attribute with a value I assign. Also, the

must have a "class" attribute with "editable" value.

This is what I have so far:

.. raw:: html 

   <div id="an_identifier">

.. class:: editable                                                                 

   paragraph content

.. raw:: html

   </div>

This is the output:

<div id="an_identifier">
    <p class="editable">paragraph content</p>
</div>

I already have got the results I was looking for, although I don't like having raw HTML embedded. My question is whether is there any directive or other method in reStructuredText to achieve the same results unobtrusively?

like image 567
nabucosound Avatar asked Oct 05 '10 14:10

nabucosound


1 Answers

Since release 0.8 (2011-07-07), you can use the container directive with a name option:

 .. container:: test
    :name: my-id

    a paragraph

results in

  <div class="test container" id="my-id">
  a paragraph
  </div>
like image 137
Günter Milde Avatar answered Oct 12 '22 23:10

Günter Milde