As mentioned by other people in the comments, this process where Sphinx changes plain "
into curled “
and so on is called SmartQuotes.
I'm not sure if you specifically wanted the literals at all in the first place, or if they were only a compromise to avoid the SmartQuotes, but there are (at least) two ways to stop the SmartQuotes without needing to use literals:
1. Disable SmartQuotes for the whole project:
If you don't want SmartQuotes, either add:
smartquotes = False
to your conf.py file
Or add a docutils.conf
file at the same level as conf.py
with this contents:
[parsers]
smart_quotes: no
(solution from this GitHub issue; see the Sphinx documentation for how these two settings interact - TL;DR: switching off in docutils.conf
will override even if they're turned on in conf.py
)
2. Escape the individual quotes you don't want to be 'smart':
You can use double-backslashes \\
to escape the quote marks you want to be straight, eg \\'
and \\"
. So in your example, this:
"\\'hour\\'h" -> "hour 9"
"ss\\'\\'SSS" -> "45\\'876"
would give output of:
“'hour'h” -> “hour 9”
“ss''SSS” -> “45'876”
with the outer double quotes left as 'smart', but I think that is the behaviour you wanted.
(see the official docutils documentation for details on escaping)