Closed cbm755 closed 5 years ago
Thank you for trying this out. I will need to debug it and see how it is being parsed as a doctree AST.
It's because we only replace things that are parsed as "paragraph". But the "where $j$ is" is parsed as a definition_list_item.
I think there was some problem matching all text
instances. Let me see if I can figure out what it was.
It's because Text
is used as a subnode of everything. So it would also match ``$...$`` in a code block, like is used in the latex()
docstring, because that's Literal(Text). I had assumed that paragraph
was the only one we cared about, but that's wrong. We should also support math in things like titles as well.
So I guess we should have a node blacklist, or should it be a whitelist?
Here are the docutils nodes https://github.com/docutils-mirror/docutils/blob/master/docutils/nodes.py.
It looks like other than literal
, most of the nodes we would want to avoid subclass from FixedTextElement.
We should probably make the blacklist configurable at any rate.
Is this a bug?
Consider a docstring containing:
Eventually renders as
(note
$j$
is still there).But if we add a new paragraph:
gives
which I assume is correct (anyway, it has no
$$
).I hit this playing with Stirling in
combinatorial/numbers.py
in SymPy.