How to strikethrough substrings without spaces in Sphinx?

121 views Asked by At

I need to strike substrings without spaces in Sphinx .rst file to transform it to HTML in a similar manner as <span style="text-decoration: line-through;">strike</span>substring. The following example is not working for me. Is it possible?

conf.py

extensions = ["sphinxnotes.strike"]

index.rst

:strike:`strike`substring
2

There are 2 answers

2
Nikolaj Š. On BEST ANSWER

It's a known peculiarity of ReStructuredText, see, e.g., Part of a word bold in reStructuredText.

All you need is an escaped space after the substring:

:strike:`strike`\ substring
0
G. Milde On

There is also the Docutils configuration setting character-level-inline-markup that lifts the no-whitespace-restriction around inline markup strings. It could be set in a docutils.conf configuration file in the same directory as setpu.py.

However, I would not recommend this for a complete Sphinx project --- you may need to escape a lot of "false positives". Exception: it may make sense in projects using a language without inter-word spaces.