fnp
/
librarian.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b63b804
)
Fix XML entities left from MathML.
author
Radek Czajka
<rczajka@rczajka.pl>
Thu, 28 May 2020 15:10:43 +0000
(17:10 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Thu, 28 May 2020 15:10:43 +0000
(17:10 +0200)
librarian/embeds/mathml.py
patch
|
blob
|
history
diff --git
a/librarian/embeds/mathml.py
b/librarian/embeds/mathml.py
index
bd58baf
..
564a9f4
100644
(file)
--- a/
librarian/embeds/mathml.py
+++ b/
librarian/embeds/mathml.py
@@
-10,6
+10,17
@@
from . import TreeEmbed, create_embed, downgrades_to
class MathML(TreeEmbed):
@downgrades_to('application/x-latex')
def to_latex(self):
class MathML(TreeEmbed):
@downgrades_to('application/x-latex')
def to_latex(self):
+ """
+ >>> print(MathML(etree.fromstring('<mat>a < b</mat>')).to_latex().data.strip())
+ a < b
+
+ >>> print(MathML(etree.fromstring('<mat>< & &lt; A</mat>')).to_latex().data.strip())
+ < & < A
+
+ """
xslt = etree.parse(get_resource('res/embeds/mathml/mathml2latex.xslt'))
output = self.tree.xslt(xslt)
xslt = etree.parse(get_resource('res/embeds/mathml/mathml2latex.xslt'))
output = self.tree.xslt(xslt)
- return create_embed('application/x-latex', data=six.text_type(output))
+ text = six.text_type(output)
+ # Workaround for entities being preserved in output. But there should be a better way.
+ text = text.replace('<', '<').replace('&', '&')
+ return create_embed('application/x-latex', data=text)