python-sphinxrestructuredtext

How to superscript a registered trademark in Sphinx/RestructuredText?


How can I superscript the ® symbol in Sphinx/RestructuredText?

This does not work, I get a superscripted |reg| instead.

bigNameBrand\ :sup:`|reg|`

Solution

  • Found a workaround by creating custom roles.

    In conf.py:

    def supsub_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
        node = docutils.nodes.superscript()
        node2 = docutils.nodes.substitution_reference(refname=text)
        node += [node2]
        return [node],[]
    
    def setup(app):
        app.add_role('supsub', supsub_role)
    

    and then:

    .. |regsup| replace:: :supsub:`reg`
    

    then you can use |regsup| to get the superscript registered trademark.