sphinx-doc/sphinx

Substitutions are not replaced in emphasized text

Closed this issue · 2 comments

Similar to #941 (Substitutions not replaced in generated index), substitutions aren't replaced in emphasized text either.

IN: *Not-working replacement of |OSSO|.*
OUT: <p><em>Not-working replacement of |OSSO|.</em></p>

pandoc does what one would expect. It appears to me that this is a bug in Sphinx. And I can't come up with any rst-trick to work around the problem.

Test case:

$ cat contents.rst 
Working replacement of |OSSO|.

*Not-working replacement of |OSSO|.*

.. |OSSO| replace:: **OSSO BV**
$ cat Makefile 
.PHONY: all pandoc sphinx 

all: pandoc sphinx

sphinx:
	@sphinx-build -b html -C . tmp-output >/dev/null
	@sed -e '/OSSO/!d;s/^/sphinx: /' tmp-output/contents.html
	@$(RM) -r tmp-output

pandoc:
	@pandoc contents.rst -t html | sed -e '/OSSO/!d;s/^/pandoc: /'
$ make
pandoc: <p>Working replacement of <strong>OSSO BV</strong>.</p>
pandoc: <p><em>Not-working replacement of <strong>OSSO BV</strong>.</em></p>
sphinx:   <p>Working replacement of <strong>OSSO BV</strong>.</p>
sphinx: <p><em>Not-working replacement of |OSSO|.</em></p>

Observe how the |OSSO| is not replaced inside the emphasized text in the sphinx case.

Versions:

$ pip freeze | grep Sphinx
Sphinx==1.5b1
$ dpkg -l pandoc | awk '/^ii/{print $3}'
1.16.0.2~dfsg-1

(Also tested with Sphinx 1.3.6 and 1.4.8.)

It comes from the specification of reStructured Text.
The docutils; a library for reST parser also does not replace the text inside emphasis element:

$ rst2html.py --link-stylesheet contents.rst
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title></title>
<link rel="stylesheet" href="../lib/python2.7/site-packages/docutils/writers/html4css1/html4css1.css" type="text/css" />
</head>
<body>
<div class="document">


<p>Working replacement of <strong>OSSO BV</strong>.</p>
<p><em>Not-working replacement of |OSSO|.</em></p>
</div>
</body>
</html>

Please request that to docutils project.
Thanks,