fnp
/
librarian.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bugfix
[librarian.git]
/
src
/
librarian
/
embeds
/
mathml.py
diff --git
a/src/librarian/embeds/mathml.py
b/src/librarian/embeds/mathml.py
index
564a9f4
..
f633fc4
100644
(file)
--- a/
src/librarian/embeds/mathml.py
+++ b/
src/librarian/embeds/mathml.py
@@
-1,8
+1,7
@@
-#
-*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
+#
This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
+#
from lxml import etree
from lxml import etree
-import six
from librarian import get_resource
from . import TreeEmbed, create_embed, downgrades_to
from librarian import get_resource
from . import TreeEmbed, create_embed, downgrades_to
@@
-11,16
+10,21
@@
class MathML(TreeEmbed):
@downgrades_to('application/x-latex')
def to_latex(self):
"""
@downgrades_to('application/x-latex')
def to_latex(self):
"""
- >>> print(MathML(etree.fromstring('<mat>a < b</mat>')).to_latex().data.strip())
+ >>> print(MathML(etree.fromstring(
+ ... '<mat>a < b</mat>'
+ ... )).to_latex().data.strip())
a < b
a < b
- >>> print(MathML(etree.fromstring('<mat>< & &lt; A</mat>')).to_latex().data.strip())
+ >>> 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)
< & < A
"""
xslt = etree.parse(get_resource('res/embeds/mathml/mathml2latex.xslt'))
output = self.tree.xslt(xslt)
- text = six.text_type(output)
- # Workaround for entities being preserved in output. But there should be a better way.
+ text = str(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)
text = text.replace('<', '<').replace('&', '&')
return create_embed('application/x-latex', data=text)