X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/d04e61819290fc8d6d71b1932c55a774014c1f05..23d025c8875cca1404f274aca7170c9db5e980e7:/src/librarian/elements/styles/mat.py?ds=sidebyside diff --git a/src/librarian/elements/styles/mat.py b/src/librarian/elements/styles/mat.py index f284695..1512c32 100644 --- a/src/librarian/elements/styles/mat.py +++ b/src/librarian/elements/styles/mat.py @@ -1,10 +1,47 @@ +# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. +# from copy import copy from ..base import WLElement class Mat(WLElement): + STRIP = True + def html_build(self, builder): e = copy(self) e.tag = 'math' e.attrib['xmlns'] = 'http://www.w3.org/1998/Math/MathML' builder.cursor.append(e) + + def epub_build(self, builder): + builder.start_element('img', {"src": builder.mathml(self)}) + builder.end_element() + + +class M(WLElement): + STRIP = True + + +class MRow(M): + pass + + +class MFenced(M): + TXT_PREFIX = '(' + TXT_SUFFIX = ')' + + +class MFrac(M): + TXT_PREFIX = '(' + TXT_SUFFIX = ')' + + def txt_after_child(self, builder, child_count): + if child_count: + builder.push_text(') / (') + + +class MSup(M): + def txt_after_child(self, builder, child_count): + if child_count: + builder.push_text(' ^ ')