21
votes

I want to use some symbols in restructuredText; how can I do this? (e.g. → in Markdown yields the "→" symbol as defined in the list of standard HTML character entities -- see also w3c reference)

Note: I don't want to require math formula support as a dependency.

4

4 Answers

19
votes

You have a large number of defined symbols via the "substitution" operator.

You have to include the definitions via .. include:: <isonum.txt> or something similar.

Most of them have the form |larr| or |rarr|.

They are defined in the docutils.parsers.rst.include installation directory. There are dozens of files which define numerous Unicode characters.

4
votes

It was my impression that rst supported Unicode; can you just type in the raw character and let docutils handle encoding for HTML?

4
votes

I think you were looking for this: http://docutils.sourceforge.net/docs/ref/rst/roles.html#raw

You can define the following role:

.. role::  raw-html(raw)
    :format: html

And then you can write:

This way :raw-html:`&rarr;`

Which renders like this:

This way →

0
votes

I had a similar problem when making html from .rst files containing the ± character in Windows using Sphinx. Changing the file encoding from windows-1252 to UTF-8 fixed it for me.

Simply open with notepad, Save As..., and change Encoding: to UTF-8