8000 feat: allow admonitions to be rendered (#242) · pypa/readme_renderer@30b5f9a · GitHub
[go: up one dir, main page]

Skip to content

Commit 30b5f9a

Browse files
mikethemandi
andauthored
feat: allow admonitions to be rendered (#242)
* 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>
1 parent cb717bf commit 30b5f9a

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

readme_renderer/clean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
"span": ["class"],
4848
"th": ["align"],
4949
"td": ["align"],
50-
"div": ["align"],
50+
"div": ["align", "class"],
5151
"h1": ["align"],
5252
"h2": ["align"],
5353
"h3": ["align"],
5454
"h4": ["align"],
5555
"h5": ["align"],
5656
"h6": ["align"],
5757
"code": ["class"],
58-
"p": ["align"],
58+
"p": ["align", "class"],
5959
"ol": ["start"],
6060
"input": ["type", "checked", "disabled"],
6161
}

tests/fixtures/test_rst_003.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<div id="required-packages">
1+
<div class="section" id="required-packages">
22
<h2>Required packages</h2>
33
<p>To run the PyPI software, you need Python 2.5+ and PostgreSQL</p>
44
</div>
5-
<div id="quick-development-setup">
5+
<div class="section" id="quick-development-setup">
66
<h2>Quick development setup</h2>
77
<p>Make sure you are sitting</p>
88
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="admonition danger">
2+
<p class="first admonition-title">!DANGER!</p>
3+
<p class="last">Will Robinson</p>
4+
</div>
5+
<div class="admonition note">
6+
<p class="first admonition-title">Note</p>
7+
<p class="last">F Sharp is a note, right?</p>
8+
</div>
9+
<div class="admonition admonition-see-also">
10+
<p class="first admonition-title">See also</p>
11+
<p class="last">A customized admonition.
12+
Read more at <a href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions" rel="nofollow">docutils</a></p>
13+
</div>
Lines changed: 11 additions & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. danger:: Will Robinson
2+
3+
.. note::
4+
5+
F Sharp is a note, right?
6+
7+
8+
.. admonition:: See also
9+
10+
A customized admonition.
11+
Read more at `docutils <https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions>`_

tests/fixtures/test_rst_docinfo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
<td>© 2017, 2018 Lele Gaifax</td></tr>
1515
</tbody>
1616
</table>
17-
<div id="pg-query">
17+
<div class="section" id="pg-query">
1818
<h2>pg_query</h2>
1919
</div>

tests/fixtures/test_rst_linkify.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<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
88
and <a href="http://postgis.refractions.net" rel="nofollow">PostGIS</a> 2.x are recommended for development and production, since these
99
support all the GeoDjango features.</p>
10-
<div id="status">
10+
<div class="section" id="status">
1111
<h2>Status</h2>
1212
<p>multigtfs is ready for your GTFS project.</p>
1313
<p>Point releases (0.4.1 to 0.4.2) should be safe, only adding features or fixing
@@ -25,11 +25,11 @@ <h2>Status</h2>
2525
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>
2626
<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>
2727
</div>
28-
<div id="example-project">
28+
<div class="section" id="example-project">
2929
<h2>Example project</h2>
3030
<p>Check out the <a href="examples/explore/README.md" rel="nofollow">example project</a>.</p>
3131
</div>
32-
<div id="development">
32+
<div class="section" id="development">
3333
<h2>Development</h2>
3434
<table>
3535
<colgroup><col>

0 commit comments

Comments
 (0)
0