Discussion:
node.rawsource gone since Sphinx 1.6
(too old to reply)
Matthew Brett
2017-07-20 22:24:20 UTC
Permalink
Hi,

Summary:

Before Sphinx 1.6, doctree nodes at the "doctree-read" event, had
filled in "rawsource" attributes. As of Sphinx 1.6, these have gone.
This is a severe problem for a popular sphinx extension for writing
math. Was the change deliberate? Can it be reversed?

Long form:

I am the developer for the texext Sphinx extension:

https://pypi.python.org/pypi/texext

Texext includes an extension "math_dollar" that replaces math between
dollars, as in LaTeX, with the longer form inline ReST markup. So:

Here's some math: $\beta = 1$.

becomes

Here's some math: :math:`\beta=1`.

I use this extension in several projects. As of Sphinx 1.6, this
extension no longer works, because the doctree passed in from the
`doctree-read` event no longer has the "rawsource" attribute, and
there are no other attributes that have all the markup I need.

To show this, here is a tiny repo with a default sphinx-quickstart
setup, a tiny extension to show the rawsource attribute in
doctree-read input, and an index.rst file of:

"""
Here's some math: $\beta=1$.
"""

https://github.com/matthew-brett/rawsource

I install sphinx==1.5.6 and run:

make clean && make html

and the test extension prints (among the usual Sphinx output):

rawsource is Here's some math: $\beta=1$. ;
astext() is Here's some math: $beta=1$. ;

Now I install sphinx==1.6.1 (or 1.6.2 or 1.6.3) and I get:

rawsource ;
astext Here’s some math: $beta=1$. ;

Unfortunately, as you can see from this output, I can't use "astext()"
because it has already processed out the backslashes, often used in
math.

I can try hunting down which commit caused this, but I thought I'd
ask, whether this was intentional, and whether y'all can think of a
way round my problem with the current sphinx API?

Cheers,

Matthew
--
You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...