From: Radek Czajka Date: Fri, 18 Dec 2020 08:53:28 +0000 (+0100) Subject: Fixed MathML in EPUB. X-Git-Tag: 1.11.1 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/ecc4f5c21f155d689a75cb3f48b154ba37501583?ds=inline;hp=d26d6a7fdcb2c6e26fd097532765b62fd17b429c Fixed MathML in EPUB. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 521ef1c..322dba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ This document records all notable changes to Librarian. +## 1.11.1 (2020-12-18) + +### Fixed +- MathML in EPUBs. + + ## 1.11 (2020-12-09) ### Added diff --git a/setup.py b/setup.py index 3a50c6c..dda645c 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def whole_tree(prefix, path): setup( name='librarian', - version='1.11', + version='1.11.1', description='Converter from WolneLektury.pl XML-based language to XHTML, TXT and other formats', author="Marek Stępniowski", author_email='marek@stepniowski.com', diff --git a/src/librarian/epub.py b/src/librarian/epub.py index a8c6680..c286903 100644 --- a/src/librarian/epub.py +++ b/src/librarian/epub.py @@ -553,7 +553,7 @@ def transform(wldoc, verbose=False, style=None, spine = output.spine - functions.reg_mathml_epub(zip) + functions.reg_mathml_epub(output) if os.path.isdir(ilustr_path): ilustr_elements = set(ilustr.get('src') diff --git a/src/librarian/functions.py b/src/librarian/functions.py index 15e931c..2899808 100644 --- a/src/librarian/functions.py +++ b/src/librarian/functions.py @@ -7,6 +7,7 @@ from __future__ import unicode_literals from lxml import etree import re +from ebooklib import epub from librarian.dcparser import Person from librarian import get_resource @@ -138,14 +139,22 @@ def reg_mathml_latex(): _register_function(mathml_latex) -def reg_mathml_epub(zipf): +def reg_mathml_epub(output): from librarian.embeds.mathml import MathML def mathml(context, trees): data = MathML(trees[0]).to_latex().to_png().data name = "math%d.png" % mathml.count mathml.count += 1 - zipf.writestr('OPS/' + name, data) + output.add_item( + epub.EpubItem( + uid='math%d' % mathml.count, + file_name=name, + media_type='image/png', + content=data + ) + ) + return name mathml.count = 0 _register_function(mathml)