Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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|`
like image 351
Jason S Avatar asked Dec 05 '25 18:12

Jason S


1 Answers

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.

like image 163
Jason S Avatar answered Dec 12 '25 12:12

Jason S