Skip to content

Commit

Permalink
feat: allow admonitions to be rendered (#242)
Browse files Browse the repository at this point in the history
* test: add test fixtures for admonitions

Create failing examples to test desired behavior.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

* feat: allow `class` attributes for `div` and `p`

docutils' admonitions renders the blocks using `class` attributes,
which can then be styled via CSS.
Allow `class` attributes to pass through the cleaner.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

* fix: add `class` to existing test fixtures

With the allowance that `class` may now be passed for `div`,
update fixtures to conform to the new directive.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
  • Loading branch information
miketheman and di authored Jun 30, 2022
1 parent cb717bf commit 30b5f9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
4 changes: 2 additions & 2 deletions readme_renderer/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
"span": ["class"],
"th": ["align"],
"td": ["align"],
"div": ["align"],
"div": ["align", "class"],
"h1": ["align"],
"h2": ["align"],
"h3": ["align"],
"h4": ["align"],
"h5": ["align"],
"h6": ["align"],
"code": ["class"],
"p": ["align"],
"p": ["align", "class"],
"ol": ["start"],
"input": ["type", "checked", "disabled"],
}
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/test_rst_003.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div id="required-packages">
<div class="section" id="required-packages">
<h2>Required packages</h2>
<p>To run the PyPI software, you need Python 2.5+ and PostgreSQL</p>
</div>
<div id="quick-development-setup">
<div class="section" id="quick-development-setup">
<h2>Quick development setup</h2>
<p>Make sure you are sitting</p>
</div>
13 changes: 13 additions & 0 deletions tests/fixtures/test_rst_admonitions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="admonition danger">
<p class="first admonition-title">!DANGER!</p>
<p class="last">Will Robinson</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">F Sharp is a note, right?</p>
</div>
<div class="admonition admonition-see-also">
<p class="first admonition-title">See also</p>
<p class="last">A customized admonition.
Read more at <a href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions" rel="nofollow">docutils</a></p>
</div>
11 changes: 11 additions & 0 deletions tests/fixtures/test_rst_admonitions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. danger:: Will Robinson

.. note::

F Sharp is a note, right?


.. admonition:: See also

A customized admonition.
Read more at `docutils <https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions>`_
2 changes: 1 addition & 1 deletion tests/fixtures/test_rst_docinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<td>© 2017, 2018 Lele Gaifax</td></tr>
</tbody>
</table>
<div id="pg-query">
<div class="section" id="pg-query">
<h2>pg_query</h2>
</div>
6 changes: 3 additions & 3 deletions tests/fixtures/test_rst_linkify.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p>It requires a spatial databases compatible with <a href="https://docs.djangoproject.com/en/dev/ref/contrib/gis/" rel="nofollow">GeoDjango</a>. <a href="http://www.postgresql.org" rel="nofollow">PostgreSQL</a> 9.x
and <a href="http://postgis.refractions.net" rel="nofollow">PostGIS</a> 2.x are recommended for development and production, since these
support all the GeoDjango features.</p>
<div id="status">
<div class="section" id="status">
<h2>Status</h2>
<p>multigtfs is ready for your GTFS project.</p>
<p>Point releases (0.4.1 to 0.4.2) should be safe, only adding features or fixing
Expand All @@ -25,11 +25,11 @@ <h2>Status</h2>
archive feeds). If you find a feed that doesn’t work, <a href="https://github.com/tulsawebdevs/django-multi-gtfs/issues" rel="nofollow">file a bug</a>!</p>
<p>See the <a href="https://github.com/tulsawebdevs/django-multi-gtfs/issues?state=open" rel="nofollow">issues list</a> for more details on bugs and feature requests.</p>
</div>
<div id="example-project">
<div class="section" id="example-project">
<h2>Example project</h2>
<p>Check out the <a href="examples/explore/README.md" rel="nofollow">example project</a>.</p>
</div>
<div id="development">
<div class="section" id="development">
<h2>Development</h2>
<table>
<colgroup><col>
Expand Down

0 comments on commit 30b5f9a

Please sign in to comment.