Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use html5 writer from docutils #3432

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Nico Di Rocco
Nicolas Duhamel
Nicolas Perriault
Nicolas Steinmetz
nkr
Paolo Melchiorre
Paul Asselin
Pavel Puchkin
Expand Down
6 changes: 3 additions & 3 deletions pelican/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import docutils.core
import docutils.io
from docutils.parsers.rst.languages import get_language as get_docutils_lang
from docutils.writers.html4css1 import HTMLTranslator, Writer
from docutils.writers.html5_polyglot import HTMLTranslator, Writer

from pelican import rstdirectives # NOQA
from pelican.cache import FileStampDataCacher
Expand Down Expand Up @@ -178,8 +178,8 @@ class RstReader(BaseReader):
"""Reader for reStructuredText files

By default the output HTML is written using
docutils.writers.html4css1.Writer and translated using a subclass of
docutils.writers.html4css1.HTMLTranslator. If you want to override it with
docutils.writers.html5_polyglot.Writer and translated using a subclass of
docutils.writers.html5_polyglot.HTMLTranslator. If you want to override it with
your own writer/translator (e.g. a HTML5-based one), pass your classes to
these two attributes. Look in the source code for details.

Expand Down
14 changes: 6 additions & 8 deletions pelican/tests/output/basic/author/alexis-metaireau.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ <h1 class="entry-title"><a href="/this-is-a-super-article.html">This is a super
<p>In <a href="/category/yeah.html">yeah</a>.</p>
<p>tags: <a href="/tag/foo.html">foo</a> <a href="/tag/bar.html">bar</a> <a href="/tag/foobar.html">foobar</a> </p>
</footer><!-- /.post-info --><p>Some content here !</p>
<div class="section" id="this-is-a-simple-title">
<section id="this-is-a-simple-title">
<h2>This is a simple title</h2>
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
<pre class="literal-block">
&gt;&gt;&gt; from ipdb import set_trace
&gt;&gt;&gt; set_trace()
</pre>
<pre class="literal-block">&gt;&gt;&gt; from ipdb import set_trace
&gt;&gt;&gt; set_trace()</pre>
<p>→ And now try with some utf8 hell: ééé</p>
</div>
</section>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
Expand All @@ -78,12 +76,12 @@ <h1><a href="/oh-yeah.html" rel="bookmark"
<p>tags: <a href="/tag/oh.html">oh</a> <a href="/tag/bar.html">bar</a> <a href="/tag/yeah.html">yeah</a> </p>Translations:
<a href="/oh-yeah-fr.html" hreflang="fr">fr</a>

</footer><!-- /.post-info --> <div class="section" id="why-not">
</footer><!-- /.post-info --> <section id="why-not">
<h2>Why not ?</h2>
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !</p>
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
</div>
</section>

<a class="readmore" href="/oh-yeah.html">read more</a>
</div><!-- /.entry-content -->
Expand Down
4 changes: 2 additions & 2 deletions pelican/tests/output/basic/category/bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ <h1 class="entry-title"><a href="/oh-yeah.html">Oh yeah !</a></h1>
<p>tags: <a href="/tag/oh.html">oh</a> <a href="/tag/bar.html">bar</a> <a href="/tag/yeah.html">yeah</a> </p>Translations:
<a href="/oh-yeah-fr.html" hreflang="fr">fr</a>

</footer><!-- /.post-info --><div class="section" id="why-not">
</footer><!-- /.post-info --><section id="why-not">
<h2>Why not ?</h2>
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !</p>
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
</div>
</section>
</article>
</aside><!-- /#featured -->
<section id="extras" class="body">
Expand Down
8 changes: 4 additions & 4 deletions pelican/tests/output/basic/category/misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ <h1><a href="/unbelievable.html" rel="bookmark"
</footer><!-- /.post-info --> <p>Or completely awesome. Depends the needs.</p>
<p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
<a class="reference external" href="/a-markdown-powered-article.html">a file-relative link to markdown-article</a></p>
<div class="section" id="testing-sourcecode-directive">
<section id="testing-sourcecode-directive">
<h2>Testing sourcecode directive</h2>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div></td></tr></table></div>
</div>
<div class="section" id="testing-another-case">
</section>
<section id="testing-another-case">
<h2>Testing another case</h2>
<p>This will now have a line number in 'custom' since it's the default in
pelican.conf, it will …</p></div>
pelican.conf, it will …</p></section>
<a class="readmore" href="/unbelievable.html">read more</a>
</div><!-- /.entry-content -->
</article></li>
Expand Down
10 changes: 4 additions & 6 deletions pelican/tests/output/basic/category/yeah.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ <h1 class="entry-title"><a href="/this-is-a-super-article.html">This is a super
<p>In <a href="/category/yeah.html">yeah</a>.</p>
<p>tags: <a href="/tag/foo.html">foo</a> <a href="/tag/bar.html">bar</a> <a href="/tag/foobar.html">foobar</a> </p>
</footer><!-- /.post-info --><p>Some content here !</p>
<div class="section" id="this-is-a-simple-title">
<section id="this-is-a-simple-title">
<h2>This is a simple title</h2>
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
<pre class="literal-block">
&gt;&gt;&gt; from ipdb import set_trace
&gt;&gt;&gt; set_trace()
</pre>
<pre class="literal-block">&gt;&gt;&gt; from ipdb import set_trace
&gt;&gt;&gt; set_trace()</pre>
<p>→ And now try with some utf8 hell: ééé</p>
</div>
</section>
</article>
</aside><!-- /#featured -->
<section id="extras" class="body">
Expand Down
16 changes: 7 additions & 9 deletions pelican/tests/output/basic/feeds/alexis-metaireau.atom.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>A Pelican Blog - Alexis Métaireau</title><link href="/" rel="alternate"></link><link href="/feeds/alexis-metaireau.atom.xml" rel="self"></link><id>/</id><updated>2013-11-17T23:29:00+00:00</updated><entry><title>This is a super article !</title><link href="/this-is-a-super-article.html" rel="alternate"></link><published>2010-12-02T10:14:00+00:00</published><updated>2013-11-17T23:29:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-12-02:/this-is-a-super-article.html</id><summary type="html">&lt;p class="first last"&gt;Multi-line metadata should be supported
<feed xmlns="http://www.w3.org/2005/Atom"><title>A Pelican Blog - Alexis Métaireau</title><link href="/" rel="alternate"></link><link href="/feeds/alexis-metaireau.atom.xml" rel="self"></link><id>/</id><updated>2013-11-17T23:29:00+00:00</updated><entry><title>This is a super article !</title><link href="/this-is-a-super-article.html" rel="alternate"></link><published>2010-12-02T10:14:00+00:00</published><updated>2013-11-17T23:29:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-12-02:/this-is-a-super-article.html</id><summary type="html">&lt;p&gt;Multi-line metadata should be supported
as well as &lt;strong&gt;inline markup&lt;/strong&gt;.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Some content here !&lt;/p&gt;
&lt;div class="section" id="this-is-a-simple-title"&gt;
&lt;section id="this-is-a-simple-title"&gt;
&lt;h2&gt;This is a simple title&lt;/h2&gt;
&lt;p&gt;And here comes the cool &lt;a class="reference external" href="http://books.couchdb.org/relax/design-documents/views"&gt;stuff&lt;/a&gt;.&lt;/p&gt;
&lt;img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" /&gt;
&lt;img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" /&gt;
&lt;pre class="literal-block"&gt;
&amp;gt;&amp;gt;&amp;gt; from ipdb import set_trace
&amp;gt;&amp;gt;&amp;gt; set_trace()
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;&amp;gt;&amp;gt;&amp;gt; from ipdb import set_trace
&amp;gt;&amp;gt;&amp;gt; set_trace()&lt;/pre&gt;
&lt;p&gt;→ And now try with some utf8 hell: ééé&lt;/p&gt;
&lt;/div&gt;
</content><category term="yeah"></category><category term="foo"></category><category term="bar"></category><category term="foobar"></category></entry><entry><title>Oh yeah !</title><link href="/oh-yeah.html" rel="alternate"></link><published>2010-10-20T10:14:00+00:00</published><updated>2010-10-20T10:14:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-10-20:/oh-yeah.html</id><content type="html">&lt;div class="section" id="why-not"&gt;
&lt;/section&gt;
</content><category term="yeah"></category><category term="foo"></category><category term="bar"></category><category term="foobar"></category></entry><entry><title>Oh yeah !</title><link href="/oh-yeah.html" rel="alternate"></link><published>2010-10-20T10:14:00+00:00</published><updated>2010-10-20T10:14:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-10-20:/oh-yeah.html</id><content type="html">&lt;section id="why-not"&gt;
&lt;h2&gt;Why not ?&lt;/h2&gt;
&lt;p&gt;After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !&lt;/p&gt;
&lt;img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" /&gt;
&lt;/div&gt;
&lt;/section&gt;
</content><category term="bar"></category><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry></feed>
6 changes: 3 additions & 3 deletions pelican/tests/output/basic/feeds/alexis-metaireau.rss.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>A Pelican Blog - Alexis Métaireau</title><link>/</link><description></description><lastBuildDate>Sun, 17 Nov 2013 23:29:00 +0000</lastBuildDate><item><title>This is a super article !</title><link>/this-is-a-super-article.html</link><description>&lt;p class="first last"&gt;Multi-line metadata should be supported
<rss version="2.0"><channel><title>A Pelican Blog - Alexis Métaireau</title><link>/</link><description></description><lastBuildDate>Sun, 17 Nov 2013 23:29:00 +0000</lastBuildDate><item><title>This is a super article !</title><link>/this-is-a-super-article.html</link><description>&lt;p&gt;Multi-line metadata should be supported
as well as &lt;strong&gt;inline markup&lt;/strong&gt;.&lt;/p&gt;
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Thu, 02 Dec 2010 10:14:00 +0000</pubDate><guid isPermaLink="false">tag:None,2010-12-02:/this-is-a-super-article.html</guid><category>yeah</category><category>foo</category><category>bar</category><category>foobar</category></item><item><title>Oh yeah !</title><link>/oh-yeah.html</link><description>&lt;div class="section" id="why-not"&gt;
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Thu, 02 Dec 2010 10:14:00 +0000</pubDate><guid isPermaLink="false">tag:None,2010-12-02:/this-is-a-super-article.html</guid><category>yeah</category><category>foo</category><category>bar</category><category>foobar</category></item><item><title>Oh yeah !</title><link>/oh-yeah.html</link><description>&lt;section id="why-not"&gt;
&lt;h2&gt;Why not ?&lt;/h2&gt;
&lt;p&gt;After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !&lt;/p&gt;
&lt;img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" /&gt;
&lt;/div&gt;
&lt;/section&gt;
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Wed, 20 Oct 2010 10:14:00 +0000</pubDate><guid isPermaLink="false">tag:None,2010-10-20:/oh-yeah.html</guid><category>bar</category><category>oh</category><category>bar</category><category>yeah</category></item></channel></rss>
Loading
Loading