From: Jan Szejko Date: Mon, 16 Apr 2018 08:28:07 +0000 (+0200) Subject: book abstracts - backend X-Git-Tag: 1.7~23 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/1df9b49c8a7378b1fb300c413c2c438b1d41b969 book abstracts - backend --- diff --git a/librarian/html.py b/librarian/html.py index defb84c..a566f71 100644 --- a/librarian/html.py +++ b/librarian/html.py @@ -32,6 +32,17 @@ def html_has_content(text): return etree.ETXPath('//p|//{%(ns)s}p|//h1|//{%(ns)s}h1' % {'ns': str(XHTMLNS)})(text) +def transform_abstrakt(abstrakt_element): + from cStringIO import StringIO + style_filename = get_stylesheet('legacy') + style = etree.parse(style_filename) + xml = etree.tostring(abstrakt_element) + document = etree.parse(StringIO(xml.replace('abstrakt', 'dlugi_cytat'))) # HACK + result = document.xslt(style) + html = re.sub('', '', etree.tostring(result)) + return re.sub(']*>', '', html) + + def transform(wldoc, stylesheet='legacy', options=None, flags=None): """Transforms the WL document to XHTML.