HTML5 docutils writer

52 views
Skip to first unread message

Pelle Nilsson

unread,
Feb 15, 2015, 8:20:44 AM2/15/15
to nikola-...@googlegroups.com
I've done a quick-and-dirty integration of this docutils writer into Nikola:

https://bitbucket.org/andre_felipe_dias/rst2html5

This creates a bit more modern HTML code. For instance:

* A <section> tag around each section.
* figure reST directive gives <figure> and <figcaption> tags instead of <div> and <div>.
* sidebar reST directive gives <aside> tag instead of <div>.

However, it is not part of the official docutils project and is not packaged for the major distros, so I'm not sure if it's wise to replace the existing rest plugin, but let med know if you are interested. It could also go into the plugins repo.

Roberto Alsina

unread,
Feb 15, 2015, 8:24:49 AM2/15/15
to nikola-...@googlegroups.com

It can totally go un the plugins repo!

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Sunyer

unread,
Jan 15, 2016, 3:37:19 PM1/15/16
to nikola-discuss
And how do you actually use that plugin? I've already installed it, but I don't really know what I have to do to make it work.

I prefer html5 over older html generated by docutils.

Roberto Alsina

unread,
Jan 15, 2016, 5:33:42 PM1/15/16
to nikola-discuss
Install it and declare your pages/posts are "rest_html5" instead of "rest", that should do the trick.

Alejandro Muñoz

unread,
Jan 16, 2016, 2:36:38 PM1/16/16
to nikola-...@googlegroups.com
I
​set the compiler 'rest_html5' for '.rst' files in my 'conf.py' file:​


COMPILERS = {
    "rest_html5": ('.rst', '.txt'),
}


​However, ​
I get this error message when building ('nikola build'):

Scanning posts.Cannot find 'rest_html5' compiler; it might require an extra plugin -- do you have it installed?

The plug-in is properly installed, and all its dependencies seem to be 'already satisfied' as well:

$ nikola plugin -i rest_html5

[2016-01-16T19:33:39Z] NOTICE: plugin: This plugin has Python dependencies.
Requirement already satisfied (use --upgrade to upgrade): rst2html5 in /home/alejandro/Proyectos/venv3/lib/python3.4/site-packages (from -r plugins/rest_html5/requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): docutils in /home/alejandro/Proyectos/venv3/lib/python3.4/site-packages (from rst2html5->-r plugins/rest_html5/requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): Genshi in /home/alejandro/Proyectos/venv3/lib/python3.4/site-packages (from rst2html5->-r plugins/rest_html5/requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): Pygments in /home/alejandro/Proyectos/venv3/lib/python3.4/site-packages (from rst2html5->-r plugins/rest_html5/requirements.txt (line 1))
Cleaning up...


So how can I fix it?




--
You received this message because you are subscribed to a topic in the Google Groups "nikola-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nikola-discuss/XVlCY1TNj9o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nikola-discus...@googlegroups.com.

Marc Sunyer

unread,
Jan 16, 2016, 3:22:55 PM1/16/16
to nikola-discuss, ral...@kde.org
I fixed it by creating a sym link form my Blog plugin directory to the virtual environment.

ln -s /My-Blog-Path/plugins/rest_html5/ /my-venv-path/lib/python3.4/site-packages/nikola/plugins/rest_html5

Thank you for your help because its been essential to know that I had to change the compiler from rest to rest_html5.

Chris Warrick

unread,
Jan 16, 2016, 3:34:36 PM1/16/16
to Nikola—Discuss

Which means we have a REALLY nasty bug with plugin loading!

--
Chris Warrick <https://chriswarrick.com/>
Sent from my Galaxy S3.

Alejandro Muñoz

unread,
Jan 16, 2016, 5:27:11 PM1/16/16
to nikola-...@googlegroups.com
Perhaps, this is a rest_html5 only issue because I also have the book_figure plugin, which is working fine.

I've just realised that the youtube directive is not working with my original "fix". However, it works if I copy the youtube.py and youtube.plugin to /My-Blog-Path/plugins/rest_html5/
​​


More of the same with chart.py and chart.plugin; I mean I need to copy these files to /My-Blog-Path/plugins/rest_html5 in order for the chart directive to work while using the rest_html5 plugin instead of the default compiler for .rst files (rest compiler). Perhaps this happens with all the files within /my-venv-path/lib/python3.4/site-packages/nikola/plugins/compile/rest directory.



--
You received this message because you are subscribed to a topic in the Google Groups "nikola-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nikola-discuss/XVlCY1TNj9o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nikola-discus...@googlegroups.com.

Chris Warrick

unread,
Jan 17, 2016, 5:22:20 AM1/17/16
to Nikola—Discuss
On 16 January 2016 at 23:26, Alejandro Muñoz <alm...@gmail.com> wrote:
> Perhaps, this is a rest_html5 only issue because I also have the book_figure
> plugin, which is working fine.
>
> I've just realised that the youtube directive is not working with my
> original "fix". However, it works if I copy the youtube.py and
> youtube.plugin to /My-Blog-Path/plugins/rest_html5/
>
>
> More of the same with chart.py and chart.plugin; I mean I need to copy these
> files to /My-Blog-Path/plugins/rest_html5 in order for the chart directive
> to work while using the rest_html5 plugin instead of the default compiler
> for .rst files (rest compiler). Perhaps this happens with all the files
> within /my-venv-path/lib/python3.4/site-packages/nikola/plugins/compile/rest
> directory.

I found out what the bug is. It’s caused by the “don’t load
unnecessary compilers” feature, which was introduced after rest_html5
was invented.

* built-in `rest_*` plugins are considered extensions for the built-in
`rest` compiler
* `rest_html5` is errorneously marked as an extension of `rest`
* if `rest` is considered unused (not in COMPILERS *and* POSTS/PAGES),
all of those plugins are not loaded

I pushed a fixed version of `rest_html5` that resolves the issues by
(a) removing the extension marker from rest_html5 and (b) warning
about the requirement to keep the original `rest` thing.

Please reinstall `rest_html5`, remove your site-packages copy, adjust
your config and test.

Fixing the original `rest` requirement would require coding in a
special case for the loader, which can be a bit complicated.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Marc Sunyer

unread,
Jan 17, 2016, 8:04:19 AM1/17/16
to nikola-discuss

I did what you told me to do and everything seems to work fine now.

Thank you very much for fixing the bug.
Reply all
Reply to author
Forward
0 new messages