X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/db91f942ce46e3af1420f3469a83257ef5aca4c2..HEAD:/src/librarian/elements/styles/mat.py diff --git a/src/librarian/elements/styles/mat.py b/src/librarian/elements/styles/mat.py index fa353f9..1512c32 100644 --- a/src/librarian/elements/styles/mat.py +++ b/src/librarian/elements/styles/mat.py @@ -1,8 +1,13 @@ +# 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' @@ -12,3 +17,31 @@ class Mat(WLElement): 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(' ^ ')