def transform_abstrakt(abstrakt_element):
style_filename = get_stylesheet('legacy')
style = etree.parse(style_filename)
- xml = etree.tostring(abstrakt_element)
- document = etree.parse(six.BytesIO(xml.replace('abstrakt', 'dlugi_cytat'))) # HACK
+ xml = etree.tostring(abstrakt_element, encoding='unicode')
+ document = etree.parse(six.StringIO(xml.replace('abstrakt', 'dlugi_cytat'))) # HACK
result = document.xslt(style)
- html = re.sub('<a name="sec[0-9]*"/>', '', etree.tostring(result))
+ html = re.sub('<a name="sec[0-9]*"/>', '', etree.tostring(result, encoding='unicode'))
return re.sub('</?blockquote[^>]*>', '', html)
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from __future__ import unicode_literals
+
+from librarian.parser import WLDocument
+from librarian.html import transform_abstrakt
+from nose.tools import *
+from .utils import get_fixture
+
+
+def test_fragments():
+ transform_abstrakt(
+ WLDocument.from_file(
+ get_fixture('text', 'abstrakt.xml'),
+ parse_dublincore=False
+ ).edoc.getroot().find('.//abstrakt')
+ )