From: Radek Czajka Date: Wed, 11 Sep 2024 13:56:58 +0000 (+0200) Subject: Move HTML from the old transform sheet. X-Git-Tag: 24.9~5 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/011b98a4661b754a0789ae78e145437b5b86e5fe Move HTML from the old transform sheet. --- diff --git a/scripts/book2html b/scripts/book2html deleted file mode 100755 index 8eadb04..0000000 --- a/scripts/book2html +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from librarian.book2anything import Book2Anything, Option - - -class Book2Html(Book2Anything): - format_name = "HTML" - ext = "html" - uses_cover = False - uses_provider = False - transform_flags = [ - Option('-r', '--raw', dest='full-page', - action='store_false', default=True, - help='output raw text for use in templates') - ] - transform_options = [ - Option('--css', dest='css'), - Option( - '-b', '--base-url', dest='base_url', metavar='URL', - help='specifies the base URL for relative image references' - ), - ] - parser_options = [ - Option('-i', '--ignore-dublin-core', dest='parse_dublincore', - action='store_false', default=True, - help='don\'t try to parse dublin core metadata') - ] - - -if __name__ == '__main__': - Book2Html.run() diff --git a/setup.py b/setup.py index 494b3f2..184db52 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,6 @@ setup( 'Pillow>=9.1.0', 'texml', 'ebooklib', - 'aeneas', 'mutagen', 'qrcode', 'requests', diff --git a/src/librarian/builders/daisy.py b/src/librarian/builders/daisy.py index c706cbd..4949879 100644 --- a/src/librarian/builders/daisy.py +++ b/src/librarian/builders/daisy.py @@ -5,8 +5,6 @@ from copy import deepcopy import subprocess import tempfile import zipfile -from aeneas.executetask import ExecuteTask -from aeneas.task import Task from lxml import etree import mutagen from librarian import OutputFile, get_resource @@ -117,75 +115,11 @@ class DaisyBuilder: directory + "book%d.mp3" % i, ) - config_string = "task_language=pol|is_text_type=unparsed|is_text_unparsed_id_regex=sec\d+$|is_text_unparsed_id_sort=numeric|os_task_file_format=tab" - task = Task(config_string=config_string) - - with tempfile.TemporaryDirectory() as temp: - syncfile = temp + "/sync" - task.audio_file_path_absolute = mp3[i] - task.text_file_path_absolute = html.get_filename() - task.sync_map_file_path_absolute = syncfile - - ExecuteTask(task).execute() - task.output_sync_map_file() - - sync = [] - with open(syncfile) as f: - for line in f: - start, end, sec = line.strip().split('\t') - start = float(start) - end = float(end) - sync.append([start, end, sec]) - - hms = format_hms(durations[i]) - elapsed_hms = format_hms(sum(durations[:i])) - - context = { - "VERSION": "1.10", - - "HHMMSSmmm": hms, - "HHMMSS": hms.split('.')[0], - "Sd": "%.1f" % durations[i], - "ELAPSED": elapsed_hms, - - "TITLE": document.meta.title, - "PUBLISHER": document.meta.publisher[0], - "YEAR": document.meta.created_at[:4], - "MONTH": document.meta.created_at[5:7], - "AUTHOR": document.meta.author.readable(), - - "NARRATOR": narrator, - } - - with open(get_resource('res/daisy/content.smil')) as f: - tree = etree.parse(f) populate(tree.getroot(), context) - seq = tree.find('//seq') - for si, item in enumerate(sync): - par = etree.SubElement(seq, 'par', id="par%06d" % (si + 1), endsync="last") - etree.SubElement( - par, - "text", - src="book%d.html#%s" % (i, item[2])) - - audio = etree.SubElement( - par, - "audio", - src="book%d.mp3" % i, - **{ - "clip-begin": "npt=%.3fs" % item[0], - "clip-end": "npt=%.3fs" % item[1], - } - ) - - zipf.writestr( + zipf.write( + syncfiles[i], directory + 'content%d.smil' % i, - etree.tostring( - tree, - xml_declaration=True, - pretty_print=True, - ), ) for fname in ('smil10.dtd', 'xhtml1-transitional.dtd', 'xhtml-lat1.ent', 'xhtml-special.ent', 'xhtml-symbol.ent'): diff --git a/src/librarian/builders/html.py b/src/librarian/builders/html.py index 0499d43..f2177ae 100644 --- a/src/librarian/builders/html.py +++ b/src/librarian/builders/html.py @@ -1,30 +1,38 @@ # This file is part of Librarian, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # +from collections import defaultdict +import os from urllib.request import urlopen from lxml import etree -from librarian.html import add_anchors, add_table_of_contents, add_table_of_themes +from librarian.html import add_table_of_contents, add_table_of_themes, add_image_sizes from librarian import OutputFile class HtmlBuilder: file_extension = "html" - with_anchors = True with_themes = True with_toc = True with_footnotes = True with_nota_red = True + with_ids = True + with_numbering = True no_externalities = False orphans = True - def __init__(self, base_url=None): + root_tag = 'div' + root_attrib = {'id': 'book-text'} + + def __init__(self, gallery_path=None, gallery_url=None, base_url=None): self._base_url = base_url + self.gallery_path = gallery_path + self.gallery_url = gallery_url - self.tree = text = etree.Element('div', **{'id': 'book-text'}) + self.tree = text = etree.Element(self.root_tag, **self.root_attrib) self.header = etree.Element('h1') self.footnotes = etree.Element('div', id='footnotes') - self.footnote_counter = 0 + self.counters = defaultdict(lambda: 1) self.nota_red = etree.Element('div', id='nota_red') @@ -61,19 +69,38 @@ class HtmlBuilder: def forget_fragment(self, name): del self.cursors[name] - def preprocess(self, document): - document._compat_assign_ordered_ids() - document._compat_assign_section_ids() - - def build(self, document, **kwargs): + def build(self, document, element=None, **kwargs): self.document = document - self.preprocess(document) - document.tree.getroot().html_build(self) + self.assign_ids(self.document.tree) + self.prepare_images() + + if element is None: + element = document.tree.getroot() + + element.html_build(self) self.postprocess(document) return self.output() + def assign_ids(self, tree): + # Assign IDs depth-first, to account for any inside. + for _e, elem in etree.iterwalk(tree, events=('end',)): + if getattr(elem, 'NUMBERING', None): + elem.assign_id(self) + + def prepare_images(self): + # Temporarily use the legacy method, before transitioning to external generators. + if self.gallery_path is None: + return + try: + os.makedirs(self.gallery_path) + except OSError: + pass + add_image_sizes(self.document.tree, self.gallery_path, self.gallery_url, self.base_url) + def output(self): + if not len(self.tree): + return None return OutputFile.from_bytes( etree.tostring( self.tree, @@ -84,7 +111,7 @@ class HtmlBuilder: ) def postprocess(self, document): - _ = document.tree.getroot().master.gettext + _ = document.tree.getroot().gettext if document.meta.translators: self.enter_fragment('header') @@ -101,8 +128,6 @@ class HtmlBuilder: if len(self.header): self.tree.insert(0, self.header) - if self.with_anchors: - add_anchors(self.tree) if self.with_nota_red and len(self.nota_red): self.tree.append(self.nota_red) if self.with_themes: @@ -110,7 +135,7 @@ class HtmlBuilder: if self.with_toc: add_table_of_contents(self.tree) - if self.footnote_counter: + if self.counters['fn'] > 1: fnheader = etree.Element("h3") fnheader.text = _("Footnotes") self.footnotes.insert(0, fnheader) @@ -133,6 +158,15 @@ class HtmlBuilder: else: cursor.text = (cursor.text or '') + text + def add_visible_number(self, element): + assert '_id' in element.attrib, etree.tostring(element) + self.start_element('a', { + 'href': f'#{element.attrib["_id"]}', + 'class': 'wl-num', + }) + self.push_text(element.attrib['_visible_numbering']) + self.end_element() + class StandaloneHtmlBuilder(HtmlBuilder): css_url = "https://static.wolnelektury.pl/css/compressed/book_text.css" @@ -148,7 +182,6 @@ class StandaloneHtmlBuilder(HtmlBuilder): head = etree.Element('head') tree.insert(0, head) - etree.SubElement(head, 'meta', charset='utf-8') etree.SubElement(head, 'title').text = document.meta.title @@ -185,23 +218,41 @@ class StandaloneHtmlBuilder(HtmlBuilder): class SnippetHtmlBuilder(HtmlBuilder): - with_anchors = False with_themes = False with_toc = False with_footnotes = False with_nota_red = False - with_refs = False + with_ids = False + with_numbering = False + + +class AbstraktHtmlBuilder(HtmlBuilder): + with_themes = False + with_toc = False + with_footnotes = False + with_nota_red = False + with_ids = False + with_numbering = False + + root_tag = 'blockquote' + root_attrib = {} + + def build(self, document, element=None, **kwargs): + if element is None: + element = document.tree.find('//abstrakt') + element.attrib['_force'] = '1' + return super().build(document, element, **kwargs) class DaisyHtmlBuilder(StandaloneHtmlBuilder): file_extension = 'xhtml' - with_anchors = False with_themes = False with_toc = False with_footnotes = False with_nota_red = False with_deep_identifiers = False no_externalities = True + with_numbering = False def output(self): tree = etree.ElementTree(self.tree) diff --git a/src/librarian/covers/marquise.py b/src/librarian/covers/marquise.py index 0b2349a..c56ae7a 100644 --- a/src/librarian/covers/marquise.py +++ b/src/librarian/covers/marquise.py @@ -16,6 +16,7 @@ class MarquiseCover(Cover): additional_logos = [] square_variant = False + background_color = '#000' width = 2100 height = 2970 margin = 100 diff --git a/src/librarian/dcparser.py b/src/librarian/dcparser.py index 910f5e1..ce03be2 100644 --- a/src/librarian/dcparser.py +++ b/src/librarian/dcparser.py @@ -87,23 +87,7 @@ class Field: return False -class DCInfo(type): - def __new__(mcs, classname, bases, class_dict): - fields = list(class_dict['FIELDS']) - - for base in bases[::-1]: - if hasattr(base, 'FIELDS'): - for field in base.FIELDS[::-1]: - try: - fields.index(field) - except ValueError: - fields.insert(0, field) - - class_dict['FIELDS'] = tuple(fields) - return super(DCInfo, mcs).__new__(mcs, classname, bases, class_dict) - - -class WorkInfo(metaclass=DCInfo): +class BookInfo: FIELDS = ( Field(DCNS('creator'), 'authors', Person, salias='author', multiple=True), @@ -140,6 +124,48 @@ class WorkInfo(metaclass=DCInfo): Field(WLNS('contentWarning'), 'content_warnings', multiple=True, required=False), Field(WLNS('developmentStage'), 'stage', required=False), + + Field(DCNS('audience'), 'audiences', text.Audience, salias='audience', multiple=True, + required=False), + + Field(DCNS('subject.period'), 'epochs', text.Epoch, salias='epoch', multiple=True, + required=False), + Field(DCNS('subject.type'), 'kinds', text.Kind, salias='kind', multiple=True, + required=False), + Field(DCNS('subject.genre'), 'genres', text.Genre, salias='genre', multiple=True, + required=False), + Field('category.legimi', 'legimi', text.LegimiCategory, required=False), + Field('category.thema.main', 'thema_main', text.MainThemaCategory, required=False), + Field('category.thema', 'thema', text.ThemaCategory, required=False, multiple=True), + Field(DCNS('subject.location'), 'location', required=False), + + Field(DCNS('contributor.translator'), 'translators', + Person, salias='translator', multiple=True, required=False), + Field(DCNS('relation.hasPart'), 'parts', WLURI, + multiple=True, required=False), + Field(DCNS('relation.isVariantOf'), 'variant_of', WLURI, + required=False), + + Field(DCNS('relation.coverImage.url'), 'cover_url', required=False), + Field(DCNS('relation.coverImage.attribution'), 'cover_by', + required=False), + Field(DCNS('relation.coverImage.source'), 'cover_source', + required=False), + # WLCover-specific. + Field(WLNS('coverBarColor'), 'cover_bar_color', required=False), + Field(WLNS('coverBoxPosition'), 'cover_box_position', required=False), + Field(WLNS('coverClass'), 'cover_class', default=['default']), + Field(WLNS('coverLogoUrl'), 'cover_logo_urls', multiple=True, + required=False), + Field(WLNS('endnotes'), 'endnotes', BoolValue, + required=False), + + Field('pdf-id', 'isbn_pdf', required=False), + Field('epub-id', 'isbn_epub', required=False), + Field('mobi-id', 'isbn_mobi', required=False), + Field('txt-id', 'isbn_txt', required=False), + Field('html-id', 'isbn_html', required=False), + ) @classmethod @@ -350,50 +376,5 @@ class WorkInfo(metaclass=DCInfo): return result -class BookInfo(WorkInfo): - FIELDS = ( - Field(DCNS('audience'), 'audiences', text.Audience, salias='audience', multiple=True, - required=False), - - Field(DCNS('subject.period'), 'epochs', text.Epoch, salias='epoch', multiple=True, - required=False), - Field(DCNS('subject.type'), 'kinds', text.Kind, salias='kind', multiple=True, - required=False), - Field(DCNS('subject.genre'), 'genres', text.Genre, salias='genre', multiple=True, - required=False), - Field('category.legimi', 'legimi', text.LegimiCategory, required=False), - Field('category.thema.main', 'thema_main', text.MainThemaCategory, required=False), - Field('category.thema', 'thema', text.ThemaCategory, required=False, multiple=True), - Field(DCNS('subject.location'), 'location', required=False), - - Field(DCNS('contributor.translator'), 'translators', - Person, salias='translator', multiple=True, required=False), - Field(DCNS('relation.hasPart'), 'parts', WLURI, - multiple=True, required=False), - Field(DCNS('relation.isVariantOf'), 'variant_of', WLURI, - required=False), - - Field(DCNS('relation.coverImage.url'), 'cover_url', required=False), - Field(DCNS('relation.coverImage.attribution'), 'cover_by', - required=False), - Field(DCNS('relation.coverImage.source'), 'cover_source', - required=False), - # WLCover-specific. - Field(WLNS('coverBarColor'), 'cover_bar_color', required=False), - Field(WLNS('coverBoxPosition'), 'cover_box_position', required=False), - Field(WLNS('coverClass'), 'cover_class', default=['default']), - Field(WLNS('coverLogoUrl'), 'cover_logo_urls', multiple=True, - required=False), - Field(WLNS('endnotes'), 'endnotes', BoolValue, - required=False), - - Field('pdf-id', 'isbn_pdf', required=False), - Field('epub-id', 'isbn_epub', required=False), - Field('mobi-id', 'isbn_mobi', required=False), - Field('txt-id', 'isbn_txt', required=False), - Field('html-id', 'isbn_html', required=False), - ) - - def parse(file_name, cls=BookInfo): return cls.from_file(file_name) diff --git a/src/librarian/document.py b/src/librarian/document.py index 7780b61..d61abb4 100644 --- a/src/librarian/document.py +++ b/src/librarian/document.py @@ -18,6 +18,9 @@ class WLDocument: tree = etree.parse(source, parser=parser) self.tree = tree tree.getroot().document = self + + self.preprocess() + self.base_meta = dcparser.BookInfo({}, { DCNS('language'): ["pol"], }, validate_required=False) @@ -33,6 +36,11 @@ class WLDocument: return self.tree.getroot().meta return master.meta + def preprocess(self): + # Change slash-verses into real verses. + for _e, elem in etree.iterwalk(self.tree, ('start',), 'strofa'): + elem.preprocess() + @property def children(self): for part_uri in self.meta.parts or []: @@ -46,76 +54,6 @@ class WLDocument: def build(self, builder, base_url=None, **kwargs): return builder(base_url=base_url).build(self, **kwargs) - def assign_ids(self, existing=None): - # Find all existing IDs. - existing = existing or set() - que = [self.tree.getroot()] - while que: - item = que.pop(0) - try: - item.normalize_insides() - except AttributeError: - pass - existing.add(item.attrib.get('id')) - que.extend(item) - - i = 1 - que = [self.tree.getroot()] - while que: - item = que.pop(0) - que.extend(item) - if item.attrib.get('id'): - continue - if not getattr(item, 'SHOULD_HAVE_ID', False): - continue - while f'e{i}' in existing: - i += 1 - item.attrib['id'] = f'e{i}' - i += 1 - - def _compat_assign_ordered_ids(self): - """ - Compatibility: ids in document order, to be roughly compatible with legacy - footnote ids. Just for testing consistency, change to some sane identifiers - at convenience. - """ - EXPR = re.compile(r'/\s', re.MULTILINE | re.UNICODE) - def _compat_assign_ordered_ids_in_elem(elem, i): - if isinstance(elem, etree._Comment): return i - elem.attrib['_compat_ordered_id'] = str(i) - i += 1 - if getattr(elem, 'HTML_CLASS', None) == 'stanza': - if elem.text: - i += len(EXPR.split(elem.text)) - 1 - for sub in elem: - i = _compat_assign_ordered_ids_in_elem(sub, i) - if sub.tail: - i += len(EXPR.split(sub.tail)) - 1 - else: - if elem.tag in ('uwaga', 'extra'): - return i - for sub in elem: - i = _compat_assign_ordered_ids_in_elem(sub, i) - return i - - _compat_assign_ordered_ids_in_elem(self.tree.getroot(), 4) - - def _compat_assign_section_ids(self): - """ - Ids in master-section order. These need to be compatible with the - #secN anchors used by WL search results page to link to fragments. - """ - def _compat_assigns_section_ids_in_elem(elem, prefix='sec'): - for i, child in enumerate(elem): - idfier = '{}{}'.format(prefix, i + 1) - try: - child.attrib['_compat_section_id'] = idfier - except: - pass - _compat_assigns_section_ids_in_elem(child, idfier + '-') - _compat_assigns_section_ids_in_elem(self.tree.getroot().master) - - def editors(self): persons = set(self.meta.editors + self.meta.technical_editors) diff --git a/src/librarian/elements/base.py b/src/librarian/elements/base.py index b0d16ed..2349f16 100644 --- a/src/librarian/elements/base.py +++ b/src/librarian/elements/base.py @@ -40,6 +40,7 @@ class WLElement(etree.ElementBase): CAN_HAVE_TEXT = True STRIP = False + NUMBERING = None text_substitutions = [ ('---', '—'), @@ -85,6 +86,15 @@ class WLElement(etree.ElementBase): except AttributeError: return parent.in_context_of(setting) + def get_context_map(self, setting, key, default=None): + parent = self.getparent() + if parent is None: + return default + try: + return getattr(parent, setting)[key] + except AttributeError: + return parent.get_context_map(setting, key, default) + def signal(self, signal): parent = self.getparent() if parent is not None: @@ -136,7 +146,8 @@ class WLElement(etree.ElementBase): for i, child in enumerate(self): if isinstance(child, WLElement): getattr(child, build_method)(builder) - elif getattr(builder, 'debug') and child.tag is etree.Comment: + # FIXME base builder api + elif getattr(builder, 'debug', False) and child.tag is etree.Comment: builder.process_comment(child) if self.CAN_HAVE_TEXT and child.tail: text = self.normalize_text(child.tail, builder) @@ -167,14 +178,21 @@ class WLElement(etree.ElementBase): attr = self.HTML_ATTR.copy() if self.HTML_CLASS: attr['class'] = self.HTML_CLASS - # always copy the id attribute (?) - if self.attrib.get('id'): - attr['id'] = self.attrib['id'] - elif getattr(self, 'SHOULD_HAVE_ID', False) and '_compat_section_id' in self.attrib: - attr['id'] = self.attrib['_compat_section_id'] + if builder.with_ids: + # always copy the id attribute (?) + if self.attrib.get('id'): + attr['id'] = self.attrib['id'] + if self.attrib.get('_id'): + attr['id'] = self.attrib['_id'] return attr def html_build(self, builder): + # Do we need a number? + numbering = self.numbering + if numbering == 'main': + if builder.with_numbering and self.has_visible_numbering: + builder.add_visible_number(self) + if self.HTML_TAG: builder.start_element( self.HTML_TAG, @@ -315,15 +333,38 @@ class WLElement(etree.ElementBase): return snipelem + @property + def numbering(self): + numbering = self.NUMBERING + if numbering is None or self.in_context_of('DISABLE_NUMBERING'): + return None + numbering = self.get_context_map('SUPPRESS_NUMBERING', numbering, numbering) + return numbering + + @property + def id_prefix(self): + prefix = self.numbering + if prefix == 'main': + # TODO: self.context.main_numbering_prefix + prefix = 'f' # default numbering prefix + return prefix + + def assign_id(self, builder): + numbering = self.numbering + if numbering: + number = str(builder.counters[numbering]) + self.attrib['_id'] = self.id_prefix + number + builder.counters[numbering] += 1 + + if numbering == 'main': + self.attrib['_visible_numbering'] = str(builder.counters['_visible']) + builder.counters['_visible'] += 1 + + if numbering == 'fn': + self.attrib['_visible_numbering'] = number + def get_link(self): - sec = getattr(self, 'SHOULD_HAVE_ID', False) and self.attrib.get('_compat_section_id') - if sec: - return sec - parent_index = self.getparent().index(self) - if parent_index: - return self.getparent()[parent_index - 1].get_link() - else: - return self.getparent().get_link() + return self.attrib.get('_id') or self.getparent().get_link() class Snippet(WLElement): diff --git a/src/librarian/elements/blocks/dedykacja.py b/src/librarian/elements/blocks/dedykacja.py index 4076541..265b268 100644 --- a/src/librarian/elements/blocks/dedykacja.py +++ b/src/librarian/elements/blocks/dedykacja.py @@ -5,7 +5,7 @@ from ..base import WLElement class Dedykacja(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_LEGACY_TOP_MARGIN = 2 diff --git a/src/librarian/elements/blocks/nota.py b/src/librarian/elements/blocks/nota.py index 8a8d8bd..dbba883 100644 --- a/src/librarian/elements/blocks/nota.py +++ b/src/librarian/elements/blocks/nota.py @@ -9,3 +9,5 @@ class Nota(WLElement): EPUB_TAG = HTML_TAG = "div" EPUB_CLASS = HTML_CLASS = "note" + + SUPPRESS_NUMBERING = {'main': 'i'} diff --git a/src/librarian/elements/comments/abstrakt.py b/src/librarian/elements/comments/abstrakt.py index 09be8ae..f54a455 100644 --- a/src/librarian/elements/comments/abstrakt.py +++ b/src/librarian/elements/comments/abstrakt.py @@ -9,7 +9,9 @@ class Abstrakt(WLElement): pass def html_build(self, builder): - pass + if not self.attrib['_force']: + return + return super().html_build(builder) def epub_build(self, builder): pass diff --git a/src/librarian/elements/drama/didaskalia.py b/src/librarian/elements/drama/didaskalia.py index ed43cae..8f461dd 100644 --- a/src/librarian/elements/drama/didaskalia.py +++ b/src/librarian/elements/drama/didaskalia.py @@ -5,7 +5,7 @@ from ..base import WLElement class Didaskalia(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_TOP_PARGIN = 2 TXT_BOTTOM_MARGIN = 2 @@ -14,5 +14,5 @@ class Didaskalia(WLElement): TXT_PREFIX = "/ " TXT_SUFFIX = " /" - EPUB_TAG =_HTML_TAG = "div" + EPUB_TAG = HTML_TAG = "div" EPUB_CLASS = HTML_CLASS = "didaskalia" diff --git a/src/librarian/elements/drama/lista_osob.py b/src/librarian/elements/drama/lista_osob.py index 0727698..f9e210d 100644 --- a/src/librarian/elements/drama/lista_osob.py +++ b/src/librarian/elements/drama/lista_osob.py @@ -6,8 +6,8 @@ from ..base import WLElement class ListaOsob(WLElement): + NUMBERING = 'i' CAN_HAVE_TEXT = False - SHOULD_HAVE_ID = True TXT_TOP_MARGIN = 3 TXT_BOTTOM_MARGIN = 3 diff --git a/src/librarian/elements/drama/lista_osoba.py b/src/librarian/elements/drama/lista_osoba.py index e4243df..2341918 100644 --- a/src/librarian/elements/drama/lista_osoba.py +++ b/src/librarian/elements/drama/lista_osoba.py @@ -5,6 +5,8 @@ from ..base import WLElement class ListaOsoba(WLElement): + NUMBERING = "i" + TXT_TOP_MARGIN = 1 TXT_BOTTOM_MARGIN = 1 TXT_LEGACY_TOP_MARGIN = 1 @@ -12,6 +14,7 @@ class ListaOsoba(WLElement): TXT_PREFIX = " * " EPUB_TAG = HTML_TAG = "li" + HTML_CLASS = "wl" def html_build(self, builder): builder.enter_fragment('list') diff --git a/src/librarian/elements/drama/miejsce_czas.py b/src/librarian/elements/drama/miejsce_czas.py index 313109c..48e748e 100644 --- a/src/librarian/elements/drama/miejsce_czas.py +++ b/src/librarian/elements/drama/miejsce_czas.py @@ -5,8 +5,9 @@ from ..paragraphs import Akap class MiejsceCzas(Akap): - SHOULD_HAVE_ID = True + NUMBERING = 'i' + + HTML_CLASS = 'wl place-and-time' EPUB_TAG = "div" - EPUB_CLASS = HTML_CLASS = 'place-and-time' - + EPUB_CLASS = 'place-and-time' diff --git a/src/librarian/elements/drama/naglowek_listy.py b/src/librarian/elements/drama/naglowek_listy.py index 646833c..0918ba8 100644 --- a/src/librarian/elements/drama/naglowek_listy.py +++ b/src/librarian/elements/drama/naglowek_listy.py @@ -5,9 +5,10 @@ from ..base import WLElement class NaglowekListy(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' HTML_TAG = "h3" + HTML_CLASS = "wl" EPUB_TAG = "div" EPUB_CLASS = "h3" diff --git a/src/librarian/elements/drama/naglowek_osoba.py b/src/librarian/elements/drama/naglowek_osoba.py index dde0c0c..43aa1d3 100644 --- a/src/librarian/elements/drama/naglowek_osoba.py +++ b/src/librarian/elements/drama/naglowek_osoba.py @@ -5,7 +5,7 @@ from ..base import WLElement class NaglowekOsoba(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_TOP_MARGIN = 3 TXT_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/figures/animacja.py b/src/librarian/elements/figures/animacja.py index 3479a02..6b0619a 100644 --- a/src/librarian/elements/figures/animacja.py +++ b/src/librarian/elements/figures/animacja.py @@ -5,7 +5,7 @@ from ..base import WLElement class Animacja(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' HTML_TAG = 'div' HTML_CLASS = "animacja cycle-slideshow" diff --git a/src/librarian/elements/figures/ilustr.py b/src/librarian/elements/figures/ilustr.py index 4e848ac..51bae4e 100644 --- a/src/librarian/elements/figures/ilustr.py +++ b/src/librarian/elements/figures/ilustr.py @@ -12,13 +12,36 @@ MAX_PNG_WEIGHT = 200000 class Ilustr(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' EPUB_TAG = HTML_TAG = 'img' def get_html_attr(self, builder): - ## TODO: thumbnail. + cls = 'ilustr' + if self.attrib.get('wyrownanie'): + cls += ' ' + self.attrib['wyrownanie'] + if self.attrib.get('oblew'): + cls += ' oblew' + attr = { + 'class': cls, + 'alt': self.attrib.get('alt', ''), + 'title': self.attrib.get('alt', ''), + 'src': self.attrib.get('src', ''), + } + if self.attrib.get('srcset'): + attr['srcset'] = self.attrib['srcset'] + attr['sizes'] = ''' + (min-width: 718px) 600px, + (min-width: 600px) calc(100vw - 118px), + (min-width: 320px) calc(100vw - 75px), + (min-width: 15em) calc(100wv - 60px), + calc(100wv - 40px) + ''' + if self.attrib.get('szer'): + attr['style'] = 'width: ' + self.attrib['szer'] + return attr + def get_epub_attr(self, builder): url = urllib.parse.urljoin( builder.base_url, self.get('src') @@ -69,5 +92,3 @@ class Ilustr(WLElement): 'alt': self.attrib.get('alt', ''), 'title': self.attrib.get('alt', ''), } - - get_epub_attr = get_html_attr diff --git a/src/librarian/elements/figures/tabela.py b/src/librarian/elements/figures/tabela.py index 737166f..783fcb6 100644 --- a/src/librarian/elements/figures/tabela.py +++ b/src/librarian/elements/figures/tabela.py @@ -5,7 +5,7 @@ from ..base import WLElement class Tabela(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' EPUB_TAG = HTML_TAG = 'table' diff --git a/src/librarian/elements/footnotes/__init__.py b/src/librarian/elements/footnotes/__init__.py index 76be8e8..a94b968 100644 --- a/src/librarian/elements/footnotes/__init__.py +++ b/src/librarian/elements/footnotes/__init__.py @@ -6,8 +6,10 @@ from ..base import WLElement class Footnote(WLElement): NO_TOC = True + DISABLE_NUMBERING = True START_INLINE = True ASIDE = True + NUMBERING = 'fn' def signal(self, signal): if signal == 'INLINE': @@ -22,10 +24,9 @@ class Footnote(WLElement): if not builder.with_footnotes: return - builder.footnote_counter += 1 - fn_no = builder.footnote_counter - footnote_id = 'footnote-idm{}'.format(self.attrib['_compat_ordered_id']) - anchor_id = 'anchor-idm{}'.format(self.attrib['_compat_ordered_id']) + fn_no = self.attrib.get('_visible_numbering') + footnote_id = 'footnote-id{}'.format(fn_no) + anchor_id = 'anchor-id{}'.format(fn_no) # Add anchor. builder.start_element( diff --git a/src/librarian/elements/front/autor_utworu.py b/src/librarian/elements/front/autor_utworu.py index 555cb92..3e35b0b 100644 --- a/src/librarian/elements/front/autor_utworu.py +++ b/src/librarian/elements/front/autor_utworu.py @@ -8,7 +8,7 @@ class AutorUtworu(HeaderElement): TXT_BOTTOM_MARGIN = 2 TXT_LEGACY_BOTTOM_MARGIN = 2 - HTML_CLASS = 'author' + HTML_CLASS = 'wl author' def epub_build(self, builder): return diff --git a/src/librarian/elements/front/base.py b/src/librarian/elements/front/base.py index 04d286e..ad16ca3 100644 --- a/src/librarian/elements/front/base.py +++ b/src/librarian/elements/front/base.py @@ -5,8 +5,8 @@ from ..base import WLElement class HeaderElement(WLElement): + NUMBERING = 'i' HTML_TAG = 'span' - SHOULD_HAVE_ID = True def txt_build(self, builder): builder.enter_fragment('header') diff --git a/src/librarian/elements/front/dzielo_nadrzedne.py b/src/librarian/elements/front/dzielo_nadrzedne.py index bbc30b1..cc70164 100644 --- a/src/librarian/elements/front/dzielo_nadrzedne.py +++ b/src/librarian/elements/front/dzielo_nadrzedne.py @@ -8,7 +8,7 @@ class DzieloNadrzedne(HeaderElement): TXT_BOTTOM_MARGIN = 1 TXT_LEGACY_BOTTOM_MARGIN = 1 - HTML_CLASS = "collection" + HTML_CLASS = "wl collection" def epub_build(self, builder): return diff --git a/src/librarian/elements/front/motto.py b/src/librarian/elements/front/motto.py index ab6d13c..a6769b8 100644 --- a/src/librarian/elements/front/motto.py +++ b/src/librarian/elements/front/motto.py @@ -5,7 +5,7 @@ from ..base import WLElement class Motto(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_LEGACY_TOP_MARGIN = 4 TXT_LEGACY_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/front/motto_podpis.py b/src/librarian/elements/front/motto_podpis.py index 3441263..199da84 100644 --- a/src/librarian/elements/front/motto_podpis.py +++ b/src/librarian/elements/front/motto_podpis.py @@ -5,9 +5,10 @@ from ..base import WLElement class MottoPodpis(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' + HTML_TAG = "p" - EPUB_CLASS = HTML_CLASS = "motto_podpis" + HTML_CLASS = "wl motto_podpis" EPUB_TAG = "div" - + EPUB_CLASS = "motto_podpis" diff --git a/src/librarian/elements/front/nazwa_utworu.py b/src/librarian/elements/front/nazwa_utworu.py index 376b932..dd40266 100644 --- a/src/librarian/elements/front/nazwa_utworu.py +++ b/src/librarian/elements/front/nazwa_utworu.py @@ -8,7 +8,7 @@ class NazwaUtworu(HeaderElement): TXT_BOTTOM_MARGIN = 1 TXT_LEGACY_BOTTOM_MARGIN = 1 - HTML_CLASS = 'title' + HTML_CLASS = 'wl title' EPUB_TAG = 'h2' EPUB_CLASS = 'intitle' diff --git a/src/librarian/elements/front/podtytul.py b/src/librarian/elements/front/podtytul.py index e602571..711b3fa 100644 --- a/src/librarian/elements/front/podtytul.py +++ b/src/librarian/elements/front/podtytul.py @@ -8,7 +8,7 @@ class Podtytul(HeaderElement): TXT_BOTTOM_MARGIN = 1 TXT_LEGACY_BOTTOM_MARGIN = 1 - HTML_CLASS = 'subtitle' + HTML_CLASS = 'wl subtitle' EPUB_TAG = 'h2' EPUB_CLASS = 'insubtitle' diff --git a/src/librarian/elements/headers/naglowek_czesc.py b/src/librarian/elements/headers/naglowek_czesc.py index 9ce9ebb..11991ae 100644 --- a/src/librarian/elements/headers/naglowek_czesc.py +++ b/src/librarian/elements/headers/naglowek_czesc.py @@ -5,8 +5,8 @@ from ..base import WLElement class NaglowekCzesc(WLElement): + NUMBERING = 's' SECTION_PRECEDENCE = 1 - SHOULD_HAVE_ID = True TXT_TOP_MARGIN = 5 TXT_BOTTOM_MARGIN = 2 @@ -14,6 +14,7 @@ class NaglowekCzesc(WLElement): TXT_LEGACY_BOTTOM_MARGIN = 0 EPUB_TAG = HTML_TAG = "h2" + HTML_CLASS = "wl" EPUB_CLASS = "h2" EPUB_START_CHUNK = True diff --git a/src/librarian/elements/headers/naglowek_podrozdzial.py b/src/librarian/elements/headers/naglowek_podrozdzial.py index 26c8049..213ec00 100644 --- a/src/librarian/elements/headers/naglowek_podrozdzial.py +++ b/src/librarian/elements/headers/naglowek_podrozdzial.py @@ -5,8 +5,8 @@ from ..base import WLElement class NaglowekPodrozdzial(WLElement): + NUMBERING = 's' SECTION_PRECEDENCE = 3 - SHOULD_HAVE_ID = True TXT_TOP_MARGIN = 3 TXT_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/headers/naglowek_rozdzial.py b/src/librarian/elements/headers/naglowek_rozdzial.py index 65194d3..502dea1 100644 --- a/src/librarian/elements/headers/naglowek_rozdzial.py +++ b/src/librarian/elements/headers/naglowek_rozdzial.py @@ -5,8 +5,8 @@ from ..base import WLElement class NaglowekRozdzial(WLElement): + NUMBERING = 's' SECTION_PRECEDENCE = 2 - SHOULD_HAVE_ID = True TXT_TOP_MARGIN = 4 TXT_BOTTOM_MARGIN = 2 @@ -14,6 +14,7 @@ class NaglowekRozdzial(WLElement): TXT_LEGACY_BOTTOM_MARGIN = 0 HTML_TAG = 'h3' + HTML_CLASS = 'wl' EPUB_TAG = 'h2' EPUB_CLASS = 'h3' diff --git a/src/librarian/elements/headers/naglowek_scena.py b/src/librarian/elements/headers/naglowek_scena.py index eb2c356..e9ea5c7 100644 --- a/src/librarian/elements/headers/naglowek_scena.py +++ b/src/librarian/elements/headers/naglowek_scena.py @@ -5,8 +5,8 @@ from ..base import WLElement class NaglowekScena(WLElement): + NUMBERING = 's' SECTION_PRECEDENCE = 2 - SHOULD_HAVE_ID = True TXT_TOP_MARGIN = 4 TXT_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/headers/podtytul_czesc.py b/src/librarian/elements/headers/podtytul_czesc.py index 6b8ed75..14c6536 100644 --- a/src/librarian/elements/headers/podtytul_czesc.py +++ b/src/librarian/elements/headers/podtytul_czesc.py @@ -5,7 +5,7 @@ from ..base import WLElement class PodtytulCzesc(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_TOP_MARGIN = 2 TXT_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/headers/podtytul_podrozdzial.py b/src/librarian/elements/headers/podtytul_podrozdzial.py index bf3fcfe..239891e 100644 --- a/src/librarian/elements/headers/podtytul_podrozdzial.py +++ b/src/librarian/elements/headers/podtytul_podrozdzial.py @@ -5,7 +5,7 @@ from ..base import WLElement class PodtytulPodrozdzial(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_TOP_MARGIN = 2 TXT_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/headers/podtytul_rozdzial.py b/src/librarian/elements/headers/podtytul_rozdzial.py index ac455c3..f24fba7 100644 --- a/src/librarian/elements/headers/podtytul_rozdzial.py +++ b/src/librarian/elements/headers/podtytul_rozdzial.py @@ -5,7 +5,7 @@ from ..base import WLElement class PodtytulRozdzial(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_TOP_MARGIN = 2 TXT_BOTTOM_MARGIN = 2 diff --git a/src/librarian/elements/paragraphs/akap.py b/src/librarian/elements/paragraphs/akap.py index 9df8492..63f74b5 100644 --- a/src/librarian/elements/paragraphs/akap.py +++ b/src/librarian/elements/paragraphs/akap.py @@ -6,15 +6,19 @@ from ..base import WLElement class Akap(WLElement): STRIP = True - SHOULD_HAVE_ID = True + NUMBERING = 'main' TXT_TOP_MARGIN = 2 TXT_BOTTOM_MARGIN = 2 TXT_LEGACY_TOP_MARGIN = 2 TXT_LEGACY_BOTTOM_MARGIN = 0 + EPUB_CLASS = 'paragraph' + HTML_TAG = 'p' - EPUB_CLASS = HTML_CLASS = 'paragraph' + HTML_CLASS = 'wl paragraph' + + has_visible_numbering = True @property def EPUB_TAG(self): diff --git a/src/librarian/elements/poetry/strofa.py b/src/librarian/elements/poetry/strofa.py index 7ce3f3a..bccb01b 100644 --- a/src/librarian/elements/poetry/strofa.py +++ b/src/librarian/elements/poetry/strofa.py @@ -8,7 +8,7 @@ from .wers import Wers class Strofa(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' TXT_TOP_MARGIN = 2 TXT_BOTTOM_MARGIN = 2 @@ -28,8 +28,8 @@ class Strofa(WLElement): ) builder.push_text('\u00a0'); builder.end_element() - - def get_verses(self): + + def preprocess(self): from librarian.parser import parser verses = [ @@ -57,15 +57,15 @@ class Strofa(WLElement): else: verses[-1].append(child) - for verse in verses: - verse.stanza = self - if len(verse) == 1 and isinstance(verse[0], Wers): - assert not (verse.text or '').strip() - assert not (verse[0].tail or '').strip() - yield verse[0] - else: - yield verse + verses = [ + verse[0] if len(verse) == 1 and isinstance(verse[0], Wers) + else verse + for verse in verses + ] + + while len(self): + self.remove(self[0]) + self.text = None - def _build_inner(self, builder, build_method): - for child in self.get_verses(): - getattr(child, build_method)(builder) + for verse in verses: + self.append(verse) diff --git a/src/librarian/elements/poetry/wers.py b/src/librarian/elements/poetry/wers.py index edc4c7c..127d5bd 100644 --- a/src/librarian/elements/poetry/wers.py +++ b/src/librarian/elements/poetry/wers.py @@ -13,7 +13,10 @@ class Wers(WLElement): TXT_LEGACY_BOTTOM_MARGIN = 0 EPUB_TAG = HTML_TAG = 'div' - EPUB_CLASS = HTML_CLASS = 'verse' + EPUB_CLASS = 'verse' + HTML_CLASS = 'wl verse' + + NUMBERING = 'main' @property def meta(self): @@ -25,3 +28,27 @@ class Wers(WLElement): super()._epub_build_inner(builder) builder.push_text('''\u00a0''') + @property + def has_visible_numbering(self): + try: + number = int(self.attrib['_visible_numbering']) + except: + return False + return number == 1 or not(number % 5) + + @property + def is_stretched(self): + return self.find('.//tab[@szer="*"]') is not None + + def get_html_attr(self, builder): + attr = super().get_html_attr(builder) + if self.is_stretched: + attr['class'] += ' verse-stretched' + return attr + + def _html_build_inner(self, builder): + if self.is_stretched: + builder.start_element('span') + super()._html_build_inner(builder) + if self.is_stretched: + builder.end_element() diff --git a/src/librarian/elements/poetry/wers_akap.py b/src/librarian/elements/poetry/wers_akap.py index 394684c..8d0a9dc 100644 --- a/src/librarian/elements/poetry/wers_akap.py +++ b/src/librarian/elements/poetry/wers_akap.py @@ -7,9 +7,7 @@ from .wers import Wers class WersAkap(Wers): TXT_PREFIX = ' ' - HTML_ATTR = { - "style": "padding-left: 1em" - } + HTML_CLASS = Wers.HTML_CLASS + ' verse-p' EPUB_ATTR = { "style": "margin-left: 1em" diff --git a/src/librarian/elements/poetry/wers_cd.py b/src/librarian/elements/poetry/wers_cd.py index 49d5a6b..2350c30 100644 --- a/src/librarian/elements/poetry/wers_cd.py +++ b/src/librarian/elements/poetry/wers_cd.py @@ -4,14 +4,12 @@ from .wers import Wers class WersCd(Wers): + HTML_CLASS = Wers.HTML_CLASS + ' verse-cont' + def _txt_build_inner(self, builder): builder.push_text(' ' * 24, prepared=True) super(WersCd, self)._txt_build_inner(builder) - HTML_ATTR = { - "style": "padding-left: 12em", - } - EPUB_ATTR = { "style": "margin-left: 12em", } diff --git a/src/librarian/elements/poetry/wers_do_prawej.py b/src/librarian/elements/poetry/wers_do_prawej.py index b3c8ae9..59e639c 100644 --- a/src/librarian/elements/poetry/wers_do_prawej.py +++ b/src/librarian/elements/poetry/wers_do_prawej.py @@ -7,6 +7,8 @@ from .wers import Wers class WersDoPrawej(Wers): TXT_PREFIX = ' ' - EPUB_ATTR = HTML_ATTR = { + HTML_CLASS = Wers.HTML_CLASS + ' verse-right' + + EPUB_ATTR = { "style": "text-align: right", } diff --git a/src/librarian/elements/poetry/wers_srodek.py b/src/librarian/elements/poetry/wers_srodek.py index b8088c5..eaef5c9 100644 --- a/src/librarian/elements/poetry/wers_srodek.py +++ b/src/librarian/elements/poetry/wers_srodek.py @@ -7,6 +7,8 @@ from .wers import Wers class WersSrodek(Wers): TXT_PREFIX = ' ' - EPUB_ATTR = HTML_ATTR = { + HTML_CLASS = Wers.HTML_CLASS + ' verse-center' + + EPUB_ATTR = { "style": "text-align: center", } diff --git a/src/librarian/elements/poetry/wers_wciety.py b/src/librarian/elements/poetry/wers_wciety.py index 8fbd175..4a2744a 100644 --- a/src/librarian/elements/poetry/wers_wciety.py +++ b/src/librarian/elements/poetry/wers_wciety.py @@ -5,6 +5,8 @@ from .wers import Wers class WersWciety(Wers): + HTML_CLASS = Wers.HTML_CLASS + ' verse-indent' + @property def typ(self): v = self.attrib.get('typ') @@ -19,7 +21,7 @@ class WersWciety(Wers): def get_html_attr(self, builder): attr = super(WersWciety, self).get_html_attr(builder) - attr['style'] = "padding-left: {}em".format(self.typ) + attr['class'] += f" verse-indent-{self.typ}" return attr def get_epub_attr(self, builder): diff --git a/src/librarian/elements/styles/www.py b/src/librarian/elements/styles/www.py index 7022d1f..4655829 100644 --- a/src/librarian/elements/styles/www.py +++ b/src/librarian/elements/styles/www.py @@ -5,10 +5,15 @@ from ..base import WLElement class WWW(WLElement): - EPUB_TAG = 'a' + HTML_TAG = EPUB_TAG = 'a' def get_epub_attr(self, builder): attr = super().get_epub_attr(builder) attr['href'] = self.text return attr + def get_html_attr(self, builder): + attr = super().get_epub_attr(builder) + attr['target'] = '_blank' + attr['href'] = self.text + return attr diff --git a/src/librarian/elements/tools/__init__.py b/src/librarian/elements/tools/__init__.py index 99f81d9..c4820b1 100644 --- a/src/librarian/elements/tools/__init__.py +++ b/src/librarian/elements/tools/__init__.py @@ -5,11 +5,13 @@ from ..base import WLElement class Numeracja(WLElement): - pass + NUMBERING = True + def assign_id(self, builder): + builder.counters['_visible'] = int(self.get('start', 1)) class Rownolegle(WLElement): - def build_epub(self, builder): + def epub_build(self, builder): for i, block in enumerate(self): attr = {"class": "rownolegly-blok"} if not i: @@ -17,16 +19,49 @@ class Rownolegle(WLElement): if i == len(self) - 1: attr['class'] += ' last' builder.start_element('div', attr) - self.build_epub(block, builder) + block.epub_build(builder) builder.end_element() + def html_build(self, builder): + for i, block in enumerate(self): + attr = {"class": "paralell-block"} + if not i: + attr['class'] += ' paralell-block-first' + if i == len(self) - 1: + attr['class'] += ' paralell-block-last' + builder.start_element('div', attr) + block.html_build(builder) + builder.end_element() + + class Tab(WLElement): EPUB_TAG = HTML_TAG = 'span' + def html_build(self, builder): + szer = self.get('szer', '1') + if szer == '*': + reopen = [] + from lxml import etree + p = builder.cursor + while 'verse' not in p.attrib.get('class', ''): + reopen.append(p) + p = p.getparent() + builder.end_element() + builder.start_element('span', {'class': 'verse-stretched-space'}) + builder.end_element() + while reopen: + p = reopen.pop() + builder.start_element(p.tag, p.attrib) + else: + super().html_build(builder) + def get_html_attr(self, builder): + szer = self.get('szer', '1').strip() + if szer.endswith('em'): + szer = szer[:-2] try: - szer = int(self.get('szer', 1)) + szer = int(szer) except: szer = 1 return { @@ -35,4 +70,3 @@ class Tab(WLElement): } get_epub_attr = get_html_attr - diff --git a/src/librarian/html.py b/src/librarian/html.py index 2919498..a96e975 100644 --- a/src/librarian/html.py +++ b/src/librarian/html.py @@ -9,43 +9,9 @@ import urllib.parse import urllib.request from lxml import etree -from librarian import XHTMLNS, ParseError, OutputFile from librarian import functions from PIL import Image -from lxml.etree import XMLSyntaxError, XSLTApplyError - - -functions.reg_substitute_entities() -functions.reg_person_name() - -STYLESHEETS = { - 'legacy': 'xslt/book2html.xslt', -} - - -def get_stylesheet(name): - return os.path.join(os.path.dirname(__file__), STYLESHEETS[name]) - - -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): - style_filename = get_stylesheet('legacy') - style = etree.parse(style_filename) - xml = etree.tostring(abstrakt_element, encoding='unicode') - document = etree.parse(io.StringIO( - xml.replace('', '', - etree.tostring(result, encoding='unicode')) - return re.sub(']*>', '', html) - def add_image_sizes(tree, gallery_path, gallery_url, base_url): widths = [360, 600, 1200, 1800, 2400] @@ -92,65 +58,6 @@ def add_image_sizes(tree, gallery_path, gallery_url, base_url): f.close() -def transform(wldoc, stylesheet='legacy', options=None, flags=None, css=None, gallery_path='img/', gallery_url='img/', base_url='file://./'): - """Transforms the WL document to XHTML. - - If output_filename is None, returns an XML, - otherwise returns True if file has been written,False if it hasn't. - File won't be written if it has no content. - """ - # Parse XSLT - try: - style_filename = get_stylesheet(stylesheet) - style = etree.parse(style_filename) - - document = copy.deepcopy(wldoc) - del wldoc - document.swap_endlines() - - if flags: - for flag in flags: - document.edoc.getroot().set(flag, 'yes') - - document.clean_ed_note() - document.clean_ed_note('abstrakt') - document.fix_pa_akap() - - if not options: - options = {} - - try: - os.makedirs(gallery_path) - except OSError: - pass - - add_image_sizes(document.edoc, gallery_path, gallery_url, base_url) - - css = ( - css - or 'https://static.wolnelektury.pl/css/compressed/book_text.css' - ) - css = "'%s'" % css - result = document.transform(style, css=css, **options) - del document # no longer needed large object :) - - if html_has_content(result): - add_anchors(result.getroot()) - add_table_of_themes(result.getroot()) - add_table_of_contents(result.getroot()) - - return OutputFile.from_bytes(etree.tostring( - result, method='html', xml_declaration=False, - pretty_print=True, encoding='utf-8' - )) - else: - return None - except KeyError: - raise ValueError("'%s' is not a valid stylesheet.") - except (XMLSyntaxError, XSLTApplyError) as e: - raise ParseError(e) - - class Fragment: def __init__(self, id, themes): super(Fragment, self).__init__() @@ -265,7 +172,7 @@ def extract_fragments(input_filename): else: # Omit annotation tags if (len(element.get('name', '')) or - element.get('class', '') in ('annotation', 'anchor')): + element.get('class', '') in ('annotation-anchor', 'anchor', 'wl-num', 'reference')): if event == 'end' and element.tail: for fragment_id in open_fragments: open_fragments[fragment_id].append( @@ -283,24 +190,16 @@ def extract_fragments(input_filename): return closed_fragments, open_fragments -def add_anchor(element, prefix, with_link=True, with_target=True, - link_text=None): +def add_anchor(element, prefix, link_text=None): parent = element.getparent() index = parent.index(element) - if with_link: - if link_text is None: - link_text = prefix - anchor = etree.Element('a', href='#%s' % prefix) - anchor.set('class', 'anchor') - anchor.text = str(link_text) - parent.insert(index, anchor) - - if with_target: - anchor_target = etree.Element('a', name='%s' % prefix) - anchor_target.set('class', 'target') - anchor_target.text = ' ' - parent.insert(index, anchor_target) + if link_text is None: + link_text = prefix + anchor = etree.Element('a', href='#%s' % prefix) + anchor.set('class', 'anchor') + anchor.text = str(link_text) + parent.insert(index, anchor) def any_ancestor(element, test): @@ -310,43 +209,9 @@ def any_ancestor(element, test): return False -def add_anchors(root): - counter = 1 - visible_counter = 1 - for element in root.iterdescendants(): - def f(e): - return ( - e.get('class') in ( - 'note', 'motto', 'motto_podpis', 'dedication', 'frame' - ) - or e.get('id') == 'nota_red' - or e.tag == 'blockquote' - or e.get('id') == 'footnotes' - ) - - if element.get('class') == 'numeracja': - try: - visible_counter = int(element.get('data-start')) - except ValueError: - visible_counter = 1 - - if any_ancestor(element, f): - continue - - if element.tag == 'div' and 'verse' in element.get('class', ''): - if visible_counter == 1 or visible_counter % 5 == 0: - add_anchor(element, "f%d" % counter, link_text=visible_counter) - counter += 1 - visible_counter += 1 - elif 'paragraph' in element.get('class', ''): - add_anchor(element, "f%d" % counter, link_text=visible_counter) - counter += 1 - visible_counter += 1 - - def raw_printable_text(element): working = copy.deepcopy(element) - for e in working.findall('a'): + for e in working.findall('.//a'): if e.get('class') in ('annotation', 'theme-begin'): e.text = '' return etree.tostring(working, method='text', encoding='unicode').strip() @@ -354,7 +219,6 @@ def raw_printable_text(element): def add_table_of_contents(root): sections = [] - counter = 1 for element in root.iterdescendants(): if element.tag in ('h2', 'h3'): if any_ancestor( @@ -368,12 +232,13 @@ def add_table_of_contents(root): if (element.tag == 'h3' and len(sections) and sections[-1][1] == 'h2'): sections[-1][3].append( - (counter, element.tag, element_text, []) + (element.attrib['id'], element.tag, element_text, []) ) else: - sections.append((counter, element.tag, element_text, [])) - add_anchor(element, "s%d" % counter, with_link=False) - counter += 1 + sections.append((element.attrib['id'], element.tag, element_text, [])) + + if not sections: + return toc = etree.Element('div') toc.set('id', 'toc') @@ -383,14 +248,14 @@ def add_table_of_contents(root): for n, section, text, subsections in sections: section_element = etree.SubElement(toc_list, 'li') - add_anchor(section_element, "s%d" % n, with_target=False, + add_anchor(section_element, n, link_text=text) if len(subsections): subsection_list = etree.SubElement(section_element, 'ol') for n1, subsection, subtext, _ in subsections: subsection_element = etree.SubElement(subsection_list, 'li') - add_anchor(subsection_element, "s%d" % n1, with_target=False, + add_anchor(subsection_element, n1, link_text=subtext) root.insert(0, toc) @@ -421,7 +286,13 @@ def add_table_of_themes(root): item = etree.SubElement(themes_li, 'a', href="#%s" % fragment) item.text = str(i + 1) item.tail = ' ' + + if not len(themes_ol): + return + root.insert(0, themes_div) + themes_div.tail = root.text + root.text = None def extract_annotations(html_path): @@ -458,8 +329,8 @@ def extract_annotations(html_path): candidate = candidate.strip() if candidate in FN_QUALIFIERS: qualifiers.append(candidate) - elif candidate.startswith('z '): - subcandidate = candidate.split()[1] + elif candidate.startswith('z\u00A0'): + subcandidate = candidate.split('\u00A0')[1].split()[0] if subcandidate in FN_QUALIFIERS: qualifiers.append(subcandidate) else: diff --git a/src/librarian/locale/pl/LC_MESSAGES/messages.po b/src/librarian/locale/pl/LC_MESSAGES/messages.po index c81c458..3c60fe2 100644 --- a/src/librarian/locale/pl/LC_MESSAGES/messages.po +++ b/src/librarian/locale/pl/LC_MESSAGES/messages.po @@ -17,26 +17,26 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.3\n" -#: src/librarian/builders/html.py:84 +#: src/librarian/builders/html.py:94 msgid "translated by" msgstr "tłum." -#: src/librarian/builders/html.py:104 +#: src/librarian/builders/html.py:118 msgid "Footnotes" msgstr "Przypisy" -#: src/librarian/elements/footnotes/__init__.py:55 +#: src/librarian/elements/footnotes/__init__.py:111 msgid "author's footnote" msgstr "przypis autorski" -#: src/librarian/elements/footnotes/__init__.py:63 +#: src/librarian/elements/footnotes/__init__.py:119 msgid "translator's footnote" msgstr "przypis tłumacza" -#: src/librarian/elements/footnotes/__init__.py:71 +#: src/librarian/elements/footnotes/__init__.py:127 msgid "editor's footnote" msgstr "przypis redakcyjny" -#: src/librarian/elements/footnotes/__init__.py:79 +#: src/librarian/elements/footnotes/__init__.py:135 msgid "source editor's footnote" msgstr "przypis edytorski" diff --git a/src/librarian/picture.py b/src/librarian/picture.py deleted file mode 100644 index 8b2c882..0000000 --- a/src/librarian/picture.py +++ /dev/null @@ -1,238 +0,0 @@ -# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. -# -from operator import and_ -import functools -import io -from .dcparser import Field, WorkInfo, DCNS -from librarian import (RDFNS, ValidationError, NoDublinCore, ParseError, WLURI) -from xml.parsers.expat import ExpatError -from os import path -from lxml import etree -from lxml.etree import (XMLSyntaxError, XSLTApplyError, Element) -import re - - -class WLPictureURI(WLURI): - _re_wl_uri = re.compile( - 'http://wolnelektury.pl/katalog/obraz/(?P[-a-z0-9]+)/?$' - ) - template = 'http://wolnelektury.pl/katalog/obraz/%s/' - - -def as_wlpictureuri_strict(text): - return WLPictureURI.strict(text) - - -class PictureInfo(WorkInfo): - """ - Dublin core metadata for a picture - """ - FIELDS = ( - Field(DCNS('language'), 'language', required=False), - Field(DCNS('subject.period'), 'epochs', salias='epoch', multiple=True), - Field(DCNS('subject.type'), 'kinds', salias='kind', multiple=True), - Field(DCNS('subject.genre'), 'genres', salias='genre', multiple=True, - required=False), - Field(DCNS('subject.style'), 'styles', salias='style', multiple=True, - required=False), - - Field(DCNS('format.dimensions'), 'dimensions', required=False), - Field(DCNS('format.checksum.sha1'), 'sha1', required=True), - Field(DCNS('description.medium'), 'medium', required=False), - Field(DCNS('description.dimensions'), 'original_dimensions', - required=False), - Field(DCNS('format'), 'mime_type', required=False), - Field(DCNS('identifier.url'), 'url', WLPictureURI, - strict=as_wlpictureuri_strict) - ) - - -class ImageStore: - EXT = ['gif', 'jpeg', 'png', 'swf', 'psd', 'bmp' - 'tiff', 'tiff', 'jpc', 'jp2', 'jpf', 'jb2', 'swc', - 'aiff', 'wbmp', 'xbm'] - MIME = ['image/gif', 'image/jpeg', 'image/png', - 'application/x-shockwave-flash', 'image/psd', 'image/bmp', - 'image/tiff', 'image/tiff', 'application/octet-stream', - 'image/jp2', 'application/octet-stream', - 'application/octet-stream', 'application/x-shockwave-flash', - 'image/iff', 'image/vnd.wap.wbmp', 'image/xbm'] - - def __init__(self, dir_): - super(ImageStore, self).__init__() - self.dir = dir_ - - def path(self, slug, mime_type): - """ - Finds file by slug and mime type in our iamge store. - Returns a file objects (perhaps should return a filename?) - """ - try: - i = self.MIME.index(mime_type) - except ValueError: - err = ValueError( - "Picture %s has unknown mime type: %s" - % (slug, mime_type) - ) - err.slug = slug - err.mime_type = mime_type - raise err - ext = self.EXT[i] - # add some common extensions tiff->tif, jpeg->jpg - return path.join(self.dir, slug + '.' + ext) - - -class WLPicture: - def __init__(self, edoc, parse_dublincore=True, image_store=None): - self.edoc = edoc - self.image_store = image_store - - root_elem = edoc.getroot() - - dc_path = './/' + RDFNS('RDF') - - if root_elem.tag != 'picture': - raise ValidationError( - "Invalid root element. Found '%s', should be 'picture'" - % root_elem.tag - ) - - if parse_dublincore: - self.rdf_elem = root_elem.find(dc_path) - - if self.rdf_elem is None: - raise NoDublinCore( - "Document has no DublinCore - which is required." - ) - - self.picture_info = PictureInfo.from_element(self.rdf_elem) - else: - self.picture_info = None - self.frame = None - - @classmethod - def from_bytes(cls, xml, *args, **kwargs): - return cls.from_file(io.BytesIO(xml), *args, **kwargs) - - @classmethod - def from_file(cls, xmlfile, parse_dublincore=True, image_store=None): - - # first, prepare for parsing - if isinstance(xmlfile, str): - file = open(xmlfile, 'rb') - try: - data = file.read() - finally: - file.close() - else: - data = xmlfile.read() - - if not isinstance(data, str): - data = data.decode('utf-8') - - data = data.replace('\ufeff', '') - - # assume images are in the same directory - if image_store is None and getattr(xmlfile, 'name', None): - image_store = ImageStore(path.dirname(xmlfile.name)) - - try: - parser = etree.XMLParser(remove_blank_text=False) - tree = etree.parse(io.BytesIO(data.encode('utf-8')), parser) - - me = cls(tree, parse_dublincore=parse_dublincore, - image_store=image_store) - me.load_frame_info() - return me - except (ExpatError, XMLSyntaxError, XSLTApplyError) as e: - raise ParseError(e) - - @property - def mime_type(self): - if self.picture_info is None: - raise ValueError( - "DC is not loaded, hence we don't know the image type." - ) - return self.picture_info.mime_type - - @property - def slug(self): - return self.picture_info.url.slug - - @property - def image_path(self): - if self.image_store is None: - raise ValueError("No image store associated with whis WLPicture.") - - return self.image_store.path(self.slug, self.mime_type) - - def image_file(self, *args, **kwargs): - return open(self.image_path, 'rb', *args, **kwargs) - - def get_sem_coords(self, sem): - area = sem.find("div[@type='rect']") - if area is None: - area = sem.find("div[@type='whole']") - return [[0, 0], [-1, -1]] - - def has_all_props(node, props): - return functools.reduce( - and_, map(lambda prop: prop in node.attrib, props) - ) - - if not has_all_props(area, ['x1', 'x2', 'y1', 'y2']): - return None - - def n(prop): return int(area.get(prop)) - return [[n('x1'), n('y1')], [n('x2'), n('y2')]] - - def partiter(self): - """ - Iterates the parts of this picture and returns them - and their metadata. - """ - # omg no support for //sem[(@type='theme') or (@type='object')] ? - for part in list(self.edoc.iterfind("//sem[@type='theme']")) +\ - list(self.edoc.iterfind("//sem[@type='object']")): - pd = {'type': part.get('type')} - - coords = self.get_sem_coords(part) - if coords is None: - continue - pd['coords'] = coords - - def want_unicode(x): - if not isinstance(x, str): - return x.decode('utf-8') - else: - return x - pd['object'] = ( - part.attrib['type'] == 'object' - and want_unicode(part.attrib.get('object', '')) - or None - ) - pd['themes'] = ( - part.attrib['type'] == 'theme' - and [part.attrib.get('theme', '')] - or [] - ) - yield pd - - def load_frame_info(self): - k = self.edoc.find("//sem[@object='kadr']") - - if k is not None: - clip = self.get_sem_coords(k) - self.frame = clip - frm = Element("sem", {"type": "frame"}) - frm.append(next(k.iter("div"))) - self.edoc.getroot().append(frm) - k.getparent().remove(k) - else: - frm = self.edoc.find("//sem[@type='frame']") - if frm: - self.frame = self.get_sem_coords(frm) - else: - self.frame = None - return self diff --git a/src/librarian/xslt/book2html.xslt b/src/librarian/xslt/book2html.xslt deleted file mode 100644 index b009345..0000000 --- a/src/librarian/xslt/book2html.xslt +++ /dev/null @@ -1,677 +0,0 @@ - - - - - - - - - - - - Książka z serwisu WolneLektury.pl - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-

Przypisy

- -
- fn- - - [] - - -

- [przypis autorski] - [przypis tłumacza] - [przypis redakcyjny] - [przypis edytorski] -

-
- - -

- [przypis autorski] - [przypis tłumacza] - [przypis redakcyjny] - [przypis edytorski] -

-
-
-
-
-
-
-
-
- - - - - - - - - -

- - -

-
- -
- - - - - - - -
-
- - - -
-

-
    - -
-
-
- - -
-
- - -
-
- - -
- -
-
- - -
-
- - - -
- - -
-
- - - - - - -
- - - - ilustr - - - oblew - - - - - - - - - - - - (min-width: 718px) 600px, - (min-width: 600px) calc(100vw - 118px), - (min-width: 320px) calc(100vw - 75px), - (min-width: 15em) calc(100wv - 60px), - calc(100wv - 40px) - - - - - - - - - - - width: - - - - - -
-
-
- - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - -

-
- - -
- - -
-
- - - -

- - -

-
- - -
- - -
-
- - - -

- - -

-
- - -
- - -
-
- - - - -

- - -

-
- - - -
- - -
-
- - -
  • -
    - - -

    - - - -

    -
    - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - - verse - - - verse-p - - - verse-indent - - verse-indent- - - - - - verse-cont - - - verse-right - - - verse-center - - - - -
    -
    - - - -

    - - -

    -
    - - - - - - - - -
    -
    - - - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - [] - - - - - - - - - - - - - - - - - - - - - - - - - - „” - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - -

    *

    -
    - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    - - - - - - tłum. - - , - - - - - - - - - - - - - - - -
    - - rownolegly-blok - - last - - - first - - - - border-left: 2px solid red; padding-left: .5em; - - border-radius: 0 0 0 .75em; - - - border-radius: .75em 0 0 0; - - - -
    -
    - - - - - - display: inline-block; width: em - - - display: inline-block; width: 1em - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - wl- - - - - - - - - - - - - - -
    diff --git a/tests/files/picture/angelus-novus.jpeg b/tests/files/picture/angelus-novus.jpeg deleted file mode 100644 index fd0394f..0000000 Binary files a/tests/files/picture/angelus-novus.jpeg and /dev/null differ diff --git a/tests/files/picture/angelus-novus.xml b/tests/files/picture/angelus-novus.xml deleted file mode 100644 index 1e70828..0000000 --- a/tests/files/picture/angelus-novus.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - Klee, Paul - Angelus Novus - Fundacja Wolne Lektury - Sekuła, Aleksandra - Kwiatkowska, Katarzyna - Trzeciak, Weronika - Modernizm - Obraz - Publikacja zrealizowana w ramach projektu Wolne Lektury (http://wolnelektury.pl). Reprodukcja cyfrowa wykonana przez Bibliotekę Narodową z egzemplarza pochodzącego ze zbiorów BN. - 31.8 × 24.2 cm - Akwarela na papierze - http://wolnelektury.pl/katalog/obraz/angelus-novus - http://katilifox.files.wordpress.com/2011/04/1190051611_angelus-novus.jpg - Muzeum Narodowe, inw. 00000000. - Domena publiczna - Paul Klee zm. 1940 - 1940 - Image - image/jpeg - 329 x 400 px - 5ed8e8d24d92017c6341c0b8cfcc414dec55b8bf - 1920 - lat - - - -
    - - -
    - - -
    - - -
    - - - - diff --git a/tests/files/tags/akap/1.expected.html b/tests/files/tags/akap/1.expected.html new file mode 100644 index 0000000..12fce96 --- /dev/null +++ b/tests/files/tags/akap/1.expected.html @@ -0,0 +1,7 @@ +
    +1

    Kali opowiedział, co zaszło, i ze słów jego pokazało się, że przyczyną wydarzenia była tylko zawziętość Fumby, gdy bowiem bitwa +już ustała, chciał jeszcze dobić dwóch Samburów i od jednego z nich otrzymał cios włócznią.

    +2

    Wiadomość rozbiegła się w mgnieniu oka między wszystkimi Wa-himami i naokół Kalego uczyniło się zbiegowisko. +W chwilę później sześciu wojowników przyniosło na włóczniach starego króla, który nie był zabity, ale ciężko ranny i przed śmiercią chciał +jeszcze zobaczyć potężnego, siedzącego na słoniu pana, prawdziwego zwycięzcę Samburu.

    +
    diff --git a/tests/files/tags/akap/1.xml b/tests/files/tags/akap/1.xml new file mode 100644 index 0000000..6cac9b6 --- /dev/null +++ b/tests/files/tags/akap/1.xml @@ -0,0 +1,6 @@ +Kali opowiedział, co zaszło, i ze słów jego pokazało się, że przyczyną wydarzenia była tylko zawziętość Fumby, gdy bowiem bitwa +już ustała, chciał jeszcze dobić dwóch Samburów i od jednego z nich otrzymał cios włócznią. + +Wiadomość rozbiegła się w mgnieniu oka między wszystkimi Wa-himami i naokół Kalego uczyniło się zbiegowisko. +W chwilę później sześciu wojowników przyniosło na włóczniach starego króla, który nie był zabity, ale ciężko ranny i przed śmiercią chciał +jeszcze zobaczyć potężnego, siedzącego na słoniu pana, prawdziwego zwycięzcę Samburu. diff --git a/tests/files/tags/akap_cd/1.expected.html b/tests/files/tags/akap_cd/1.expected.html new file mode 100644 index 0000000..00861ef --- /dev/null +++ b/tests/files/tags/akap_cd/1.expected.html @@ -0,0 +1,3 @@ +
    +1

    dalszy-ciąg-akapitu

    +
    diff --git a/tests/files/tags/akap_cd/1.xml b/tests/files/tags/akap_cd/1.xml new file mode 100644 index 0000000..2b818c4 --- /dev/null +++ b/tests/files/tags/akap_cd/1.xml @@ -0,0 +1 @@ + dalszy-ciąg-akapitu diff --git a/tests/files/tags/akap_dialog/1.expected.html b/tests/files/tags/akap_dialog/1.expected.html new file mode 100644 index 0000000..a8d3556 --- /dev/null +++ b/tests/files/tags/akap_dialog/1.expected.html @@ -0,0 +1,9 @@ +
    +1

    — Nel, potrafisz wyliczyć nasze podróże od Fajumu? — pytał Staś.

    +2

    — Potrafię.

    +3

    To mówiąc dziewczynka podniosła w górę brwi i zaczęła rachować na paluszkach.

    +4

    — Zaraz. Od Fajumu do Chartumu — to jedna; od Chartumu do Faszody — to druga; od Faszody do tego wąwozu, w którym znaleźliśmy +Kinga — to trzecia; a od Góry Lindego do jeziora — to czwarta.

    +5

    — Tak. Chyba nie ma na świecie drugiej muchy, która by przeleciała taki kawał Afryki.

    +6

    — Ładnie by ta mucha wyglądała bez ciebie!

    +
    diff --git a/tests/files/tags/akap_dialog/1.xml b/tests/files/tags/akap_dialog/1.xml new file mode 100644 index 0000000..5c05965 --- /dev/null +++ b/tests/files/tags/akap_dialog/1.xml @@ -0,0 +1,12 @@ +--- Nel, potrafisz wyliczyć nasze podróże od Fajumu? --- pytał Staś. + +--- Potrafię. + +To mówiąc dziewczynka podniosła w górę brwi i zaczęła rachować na paluszkach. + +--- Zaraz. Od Fajumu do Chartumu --- to jedna; od Chartumu do Faszody --- to druga; od Faszody do tego wąwozu, w którym znaleźliśmy +Kinga --- to trzecia; a od Góry Lindego do jeziora --- to czwarta. + +--- Tak. Chyba nie ma na świecie drugiej muchy, która by przeleciała taki kawał Afryki. + +--- Ładnie by ta mucha wyglądała bez ciebie! diff --git a/tests/files/tags/animacja/1.expected.html b/tests/files/tags/animacja/1.expected.html new file mode 100644 index 0000000..b38a92e --- /dev/null +++ b/tests/files/tags/animacja/1.expected.html @@ -0,0 +1,4 @@ +
    + Wieloryb + Kot +
    diff --git a/tests/files/tags/animacja/1.xml b/tests/files/tags/animacja/1.xml new file mode 100644 index 0000000..f97c6a0 --- /dev/null +++ b/tests/files/tags/animacja/1.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/files/tags/autor_utworu/1.expected.html b/tests/files/tags/autor_utworu/1.expected.html new file mode 100644 index 0000000..bd35ca0 --- /dev/null +++ b/tests/files/tags/autor_utworu/1.expected.html @@ -0,0 +1 @@ +

    Hans Christian Andersen

    diff --git a/tests/files/tags/autor_utworu/1.xml b/tests/files/tags/autor_utworu/1.xml new file mode 100644 index 0000000..d6a7534 --- /dev/null +++ b/tests/files/tags/autor_utworu/1.xml @@ -0,0 +1 @@ +Hans Christian Andersen diff --git a/tests/files/tags/base.xml b/tests/files/tags/base.xml new file mode 100644 index 0000000..cf6f61f --- /dev/null +++ b/tests/files/tags/base.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/files/tags/dedykacja/1.expected.html b/tests/files/tags/dedykacja/1.expected.html new file mode 100644 index 0000000..83995b5 --- /dev/null +++ b/tests/files/tags/dedykacja/1.expected.html @@ -0,0 +1,11 @@ +
    +

    +Władysław Stanisław ReymontChłopiCzęść pierwsza — Jesień +

    +
    +
    +1
    Miriamowi
    +
    (Zenonowi Przesmyckiemu)
    +
    +
    +
    diff --git a/tests/files/tags/dedykacja/1.xml b/tests/files/tags/dedykacja/1.xml new file mode 100644 index 0000000..c4a4da6 --- /dev/null +++ b/tests/files/tags/dedykacja/1.xml @@ -0,0 +1,10 @@ +Władysław Stanisław Reymont +Chłopi +Część pierwsza --- Jesień + + + +Miriamowi/ +(Zenonowi Przesmyckiemu) + + diff --git a/tests/files/tags/didask_tekst/1.expected.html b/tests/files/tags/didask_tekst/1.expected.html new file mode 100644 index 0000000..33b94f3 --- /dev/null +++ b/tests/files/tags/didask_tekst/1.expected.html @@ -0,0 +1,7 @@ +
    +1
    Oto, co może mówić kochające serce.
    +
    Do Filinta, który się śmieje
    +
    Och, śmiejcie się do syta, panowie szyderce,
    +
    A ja cenię to wyżej niż te sztuczne kwiatki,
    +5
    Te fałszywe brylanty waszej muzy gładkiej.
    +
    diff --git a/tests/files/tags/didask_tekst/1.xml b/tests/files/tags/didask_tekst/1.xml new file mode 100644 index 0000000..cdbb022 --- /dev/null +++ b/tests/files/tags/didask_tekst/1.xml @@ -0,0 +1,5 @@ +Oto, co może mówić kochające serce./ +Do Filinta, który się śmieje/ +Och, śmiejcie się do syta, panowie szyderce,/ +A ja cenię to wyżej niż te sztuczne kwiatki,/ +Te fałszywe brylanty waszej muzy gładkiej. diff --git a/tests/files/tags/didaskalia/1.expected.html b/tests/files/tags/didaskalia/1.expected.html new file mode 100644 index 0000000..efefbab --- /dev/null +++ b/tests/files/tags/didaskalia/1.expected.html @@ -0,0 +1,27 @@ +
    +

    CZEŚNIK

    +
    +
    obracając się ku niemu
    +
    +1
    Tu sęk właśnie!
    +Na toż bym się, mocium panie,
    Kawalerstwa dziś wyrzekał,
    +
    +
    uderzając w stół
    +
    +
    By kto... niech go piorun trzaśnie!
    +
    Długo będzie na to czekał,
    +
    +
    po krótkim milczeniu, biorąc talerz
    +
    +5
    Ma dochody wprawdzie znaczne —
    +
    Podstolina ma znaczniejsze;
    +
    Z wdówką zatem działać zacznę.
    +
    +
    po krótkim milczeniu
    +
    +
    Bawi z nami — w domu Klary,
    +
    Bo krewniaczka jej daleka,
    +10
    Ale mnie się wszystko zdaje...
    +
    +
    +
    diff --git a/tests/files/tags/didaskalia/1.xml b/tests/files/tags/didaskalia/1.xml new file mode 100644 index 0000000..466d912 --- /dev/null +++ b/tests/files/tags/didaskalia/1.xml @@ -0,0 +1,34 @@ +CZEŚNIK + + +obracając się ku niemu + + +Tu sęk właśnie! +Na toż bym się, mocium panie,/ +Kawalerstwa dziś wyrzekał, + + +uderzając w stół + + +By kto... niech go piorun trzaśnie!/ +Długo będzie na to czekał, + + +po krótkim milczeniu, biorąc talerz + + +Ma dochody wprawdzie znaczne ---/ +Podstolina ma znaczniejsze;/ +Z wdówką zatem działać zacznę. + + +po krótkim milczeniu + + +Bawi z nami --- w domu Klary,/ +Bo krewniaczka jej daleka,/ +Ale mnie się wszystko zdaje... + + diff --git a/tests/files/tags/dlugi_cytat/1.expected.html b/tests/files/tags/dlugi_cytat/1.expected.html new file mode 100644 index 0000000..6872c0b --- /dev/null +++ b/tests/files/tags/dlugi_cytat/1.expected.html @@ -0,0 +1,3 @@ +
    +1

    blok-akapitow-cytatu

    +
    diff --git a/tests/files/tags/dlugi_cytat/1.xml b/tests/files/tags/dlugi_cytat/1.xml new file mode 100644 index 0000000..1c38349 --- /dev/null +++ b/tests/files/tags/dlugi_cytat/1.xml @@ -0,0 +1 @@ + blok-akapitow-cytatu diff --git a/tests/files/tags/dzielo_nadrzedne/1.expected.html b/tests/files/tags/dzielo_nadrzedne/1.expected.html new file mode 100644 index 0000000..e1a18ac --- /dev/null +++ b/tests/files/tags/dzielo_nadrzedne/1.expected.html @@ -0,0 +1,3 @@ +

    +Bruno JasieńskiBut w butonierceDeszcz +

    diff --git a/tests/files/tags/dzielo_nadrzedne/1.xml b/tests/files/tags/dzielo_nadrzedne/1.xml new file mode 100644 index 0000000..6327806 --- /dev/null +++ b/tests/files/tags/dzielo_nadrzedne/1.xml @@ -0,0 +1,3 @@ +Bruno Jasieński +But w butonierce +Deszcz diff --git a/tests/files/tags/ilustr/1.expected.html b/tests/files/tags/ilustr/1.expected.html new file mode 100644 index 0000000..3b8fc76 --- /dev/null +++ b/tests/files/tags/ilustr/1.expected.html @@ -0,0 +1 @@ +
    Kot
    diff --git a/tests/files/tags/ilustr/1.xml b/tests/files/tags/ilustr/1.xml new file mode 100644 index 0000000..ec62695 --- /dev/null +++ b/tests/files/tags/ilustr/1.xml @@ -0,0 +1 @@ + diff --git a/tests/files/tags/indeks_dolny/1.expected.html b/tests/files/tags/indeks_dolny/1.expected.html new file mode 100644 index 0000000..a42c881 --- /dev/null +++ b/tests/files/tags/indeks_dolny/1.expected.html @@ -0,0 +1,3 @@ +
    +1

    H2O.

    +
    diff --git a/tests/files/tags/indeks_dolny/1.xml b/tests/files/tags/indeks_dolny/1.xml new file mode 100644 index 0000000..fd8a247 --- /dev/null +++ b/tests/files/tags/indeks_dolny/1.xml @@ -0,0 +1,3 @@ + + H2O. + diff --git a/tests/files/tags/kwestia/1.expected.html b/tests/files/tags/kwestia/1.expected.html new file mode 100644 index 0000000..2fe9773 --- /dev/null +++ b/tests/files/tags/kwestia/1.expected.html @@ -0,0 +1,15 @@ +
    +

    PUSTELNIK

    +
    +1
    Więc jako dawniej czynili mocarze,
    +
    Z Lechem się mieniał Scyta na obrączki;
    +
    A pokochawszy mocniej sercem, w darze
    +
    Dał mu koronę... stąd nasza korona.
    +5
    Zbawiciel niegdyś wyciągając rączki
    +
    Szedł do niej z matki zadumanej łona
    +
    I ku rubinom podawał się cały
    +
    Jako różyczka z liści wychylona,
    +
    I wołał: caca! i na brylant biały
    +10
    Różanych ustek perełkami świecił.
    +
    +
    diff --git a/tests/files/tags/kwestia/1.xml b/tests/files/tags/kwestia/1.xml new file mode 100644 index 0000000..a8fc460 --- /dev/null +++ b/tests/files/tags/kwestia/1.xml @@ -0,0 +1,16 @@ +PUSTELNIK + + + +Więc jako dawniej czynili mocarze,/ +Z Lechem się mieniał Scyta na obrączki;/ +A pokochawszy mocniej sercem, w darze/ +Dał mu koronę... stąd nasza korona./ +Zbawiciel niegdyś wyciągając rączki/ +Szedł do niej z matki zadumanej łona/ +I ku rubinom podawał się cały/ +Jako różyczka z liści wychylona,/ +I wołał: caca! i na brylant biały/ +Różanych ustek perełkami świecił. + + diff --git a/tests/files/tags/kwestia/2.expected.html b/tests/files/tags/kwestia/2.expected.html new file mode 100644 index 0000000..5783d97 --- /dev/null +++ b/tests/files/tags/kwestia/2.expected.html @@ -0,0 +1,11 @@ +
    +

    GŁOS HESI

    +
    +1

    Mamuńciu, tak zimno! troszkę ciepłej wody...

    +
    +

    DULSKA

    +
    +2

    Jeszcze czego? Hartujcie się... Felicjan! wstajesz? Wiesz? ten błazen, twój syn, nie wrócił jeszcze do domu! Co? nic nie mówisz? naturalnie. +Ojciec toleruje. Niedaleko padło jabłko od jabłoni. Ale jak będą dłużki małe — nie zapłacę.

    +
    +
    diff --git a/tests/files/tags/kwestia/2.xml b/tests/files/tags/kwestia/2.xml new file mode 100644 index 0000000..f4f053d --- /dev/null +++ b/tests/files/tags/kwestia/2.xml @@ -0,0 +1,16 @@ +GŁOS HESI + + + +Mamuńciu, tak zimno! troszkę ciepłej wody... + + + +DULSKA + + + +Jeszcze czego? Hartujcie się... Felicjan! wstajesz? Wiesz? ten błazen, twój syn, nie wrócił jeszcze do domu! Co? nic nie mówisz? naturalnie. +Ojciec toleruje. Niedaleko padło jabłko od jabłoni. Ale jak będą dłużki małe --- nie zapłacę. + + diff --git a/tests/files/tags/lista_osob/1.expected.html b/tests/files/tags/lista_osob/1.expected.html new file mode 100644 index 0000000..01617a4 --- /dev/null +++ b/tests/files/tags/lista_osob/1.expected.html @@ -0,0 +1,21 @@ +
    +

    +SofoklesAntygona +

    +
    +

    OSOBY DRAMATU

    +
      +
    1. ANTYGONA, córka Edypa
    2. +
    3. ISMENA, jej siostra
    4. +
    5. CHÓR TEBANSKICH STARCÓW
    6. +
    7. KREON, król Teb
    8. +
    9. STRAŻNIK
    10. +
    11. HAJMON, syn Kreona
    12. +
    13. TYREZJASZ, wróżbita
    14. +
    15. POSŁANIEC.
    16. +
    17. EURYDYKA, żona Kreona
    18. +
    19. POSŁANIEC drugi
    20. +
    +
    +

    Rzecz dzieje się przed dworcem królewskim w Tebach

    +
    diff --git a/tests/files/tags/lista_osob/1.xml b/tests/files/tags/lista_osob/1.xml new file mode 100644 index 0000000..c6f4e24 --- /dev/null +++ b/tests/files/tags/lista_osob/1.xml @@ -0,0 +1,21 @@ +Sofokles +Antygona + + + +OSOBY DRAMATU + +ANTYGONA, córka Edypa +ISMENA, jej siostra +CHÓR TEBANSKICH STARCÓW +KREON, król Teb +STRAŻNIK +HAJMON, syn Kreona +TYREZJASZ, wróżbita +POSŁANIEC. +EURYDYKA, żona Kreona +POSŁANIEC drugi + + + +Rzecz dzieje się przed dworcem królewskim w Tebach diff --git a/tests/files/tags/mat/1.expected.html b/tests/files/tags/mat/1.expected.html new file mode 100644 index 0000000..1a9163a --- /dev/null +++ b/tests/files/tags/mat/1.expected.html @@ -0,0 +1,42 @@ +
    +1

    Oznaczmy odległość tych miejsc przez δ, + dalej odległość kliszy od kondensatora przez h, + długość płyt metalowych kondensatora przez l, + natężenie pola elektryczności przez F, + masę elektronu przez m, + jego ładunek przez e, + a prędkość przez v. + Możemy wyprowadzić wzór następujący + + δ + = + + + e + ⁢ + F + ⁢ + l + × + + + l + 2 + + + + h + + + + + m + ⁢ + + v + 2 + + + + +

    +
    diff --git a/tests/files/tags/mat/1.xml b/tests/files/tags/mat/1.xml new file mode 100644 index 0000000..8c60418 --- /dev/null +++ b/tests/files/tags/mat/1.xml @@ -0,0 +1,41 @@ + + Oznaczmy odległość tych miejsc przez δ, + dalej odległość kliszy od kondensatora przez h, + długość płyt metalowych kondensatora przez l, + natężenie pola elektryczności przez F, + masę elektronu przez m, + jego ładunek przez e, + a prędkość przez v. + Możemy wyprowadzić wzór następujący + + δ + = + + + e + ⁢ + F + ⁢ + l + × + + + l + 2 + + + + h + + + + + m + ⁢ + + v + 2 + + + + + diff --git a/tests/files/tags/motto/1.expected.html b/tests/files/tags/motto/1.expected.html new file mode 100644 index 0000000..6f71f42 --- /dev/null +++ b/tests/files/tags/motto/1.expected.html @@ -0,0 +1,11 @@ +
    +

    +Aleksander FredroZemsta +

    +
    +1

    Nie masz nic tak złego, żeby się na dobre nie przydało. Bywa z węża dryjakiew, złe często dobremu okazyją daje.

    +
    +

    +And. Maks. Fredro +

    +
    diff --git a/tests/files/tags/motto/1.xml b/tests/files/tags/motto/1.xml new file mode 100644 index 0000000..e3aec09 --- /dev/null +++ b/tests/files/tags/motto/1.xml @@ -0,0 +1,10 @@ +Aleksander Fredro +Zemsta + + +Nie masz nic tak złego, żeby się na dobre nie przydało. Bywa z węża dryjakiew, złe często dobremu okazyją daje. + + + +And. Maks. Fredro + diff --git a/tests/files/tags/motto_podpis/1.expected.html b/tests/files/tags/motto_podpis/1.expected.html new file mode 100644 index 0000000..1ff589b --- /dev/null +++ b/tests/files/tags/motto_podpis/1.expected.html @@ -0,0 +1,13 @@ +
    +

    +Adam MickiewiczKonrad WallenrodPowieść historyczna(Z dziejów litewskich i pruskich) +

    +
    +
    +1
    Dovete adunque sapere come sono/ +due generazioni da combattere...../ +bisogna essere volpe e leone.
    +
    +
    +

    MACCHIAVELLI

    +
    diff --git a/tests/files/tags/motto_podpis/1.xml b/tests/files/tags/motto_podpis/1.xml new file mode 100644 index 0000000..709b324 --- /dev/null +++ b/tests/files/tags/motto_podpis/1.xml @@ -0,0 +1,14 @@ +Adam Mickiewicz +Konrad Wallenrod +Powieść historyczna +(Z dziejów litewskich i pruskich) + + + +Dovete adunque sapere come sono/ +due generazioni da combattere...../ +bisogna essere volpe e leone. + + + +MACCHIAVELLI diff --git a/tests/files/tags/naglowek_akt/1.expected.html b/tests/files/tags/naglowek_akt/1.expected.html new file mode 100644 index 0000000..f5c0f26 --- /dev/null +++ b/tests/files/tags/naglowek_akt/1.expected.html @@ -0,0 +1,12 @@ +
    +
    +

    Spis treści

    +
      +AKT PIERWSZY
      1. +SCENA PIERWSZA
      2. +
    1. +
    +
    +

    AKT PIERWSZY

    +

    SCENA PIERWSZA

    +
    diff --git a/tests/files/tags/naglowek_akt/1.xml b/tests/files/tags/naglowek_akt/1.xml new file mode 100644 index 0000000..85d24ec --- /dev/null +++ b/tests/files/tags/naglowek_akt/1.xml @@ -0,0 +1,4 @@ +AKT PIERWSZY + +Pokój w zamku Cześnika, drzwi na prawo, lewo i w środku, stoły, krzesła etc., gitara angielska na ścianie. +SCENA PIERWSZA diff --git a/tests/files/tags/naglowek_czesc/1.expected.html b/tests/files/tags/naglowek_czesc/1.expected.html new file mode 100644 index 0000000..d59489e --- /dev/null +++ b/tests/files/tags/naglowek_czesc/1.expected.html @@ -0,0 +1,22 @@ +
    +
    +

    Spis treści

    +
      +PIEŚŃ I
    1. +
    +
    +

    +Juliusz SłowackiBeniowski +

    +

    PIEŚŃ I

    +
    +1
    Za panowania króla Stanisława
    +
    Mieszkał ubogi szlachcic na Podolu,
    +
    Wysoko potem go wyniosła sława;
    +
    Szczęścia miał mało w życiu, więcej bolu;
    +5
    Albowiem była to epoka krwawa,
    +
    I kraj był cały na rumaku, w polu;
    +
    Łany, ogrody leżały odłogiem,
    +
    Zaraza stała u domu za progiem.
    +
    +
    diff --git a/tests/files/tags/naglowek_czesc/1.xml b/tests/files/tags/naglowek_czesc/1.xml new file mode 100644 index 0000000..3859aad --- /dev/null +++ b/tests/files/tags/naglowek_czesc/1.xml @@ -0,0 +1,15 @@ +Juliusz Słowacki +Beniowski + +PIEŚŃ I + + +Za panowania króla Stanisława/ +Mieszkał ubogi szlachcic na Podolu,/ +Wysoko potem go wyniosła sława;/ +Szczęścia miał mało w życiu, więcej bolu;/ +Albowiem była to epoka krwawa,/ +I kraj był cały na rumaku, w polu;/ +Łany, ogrody leżały odłogiem,/ +Zaraza stała u domu za progiem. + diff --git a/tests/files/tags/naglowek_osoba/1.expected.html b/tests/files/tags/naglowek_osoba/1.expected.html new file mode 100644 index 0000000..4903bb3 --- /dev/null +++ b/tests/files/tags/naglowek_osoba/1.expected.html @@ -0,0 +1,13 @@ +
    +

    CZEŚNIK

    +
    +
    jakby do siebie
    +
    +1
    Piękne dobra w każdym względzie —
    +
    Lasy — gleba wyśmienita —
    +
    Dobrą żoną pewnie będzie —
    +
    Co za czynsze! — To kobiéta!...
    +5
    Trzy folwarki!
    +
    +
    +
    diff --git a/tests/files/tags/naglowek_osoba/1.xml b/tests/files/tags/naglowek_osoba/1.xml new file mode 100644 index 0000000..2aa172a --- /dev/null +++ b/tests/files/tags/naglowek_osoba/1.xml @@ -0,0 +1,12 @@ +CZEŚNIK + + +jakby do siebie + +Piękne dobra w każdym względzie ---/ +Lasy --- gleba wyśmienita ---/ +Dobrą żoną pewnie będzie ---/ +Co za czynsze! --- To kobiéta!.../ +Trzy folwarki! +... + diff --git a/tests/files/tags/naglowek_podrozdzial/1.expected.html b/tests/files/tags/naglowek_podrozdzial/1.expected.html new file mode 100644 index 0000000..1194ffb --- /dev/null +++ b/tests/files/tags/naglowek_podrozdzial/1.expected.html @@ -0,0 +1 @@ +

    numer-i/lub-tytuł-podrozdziału

    diff --git a/tests/files/tags/naglowek_podrozdzial/1.xml b/tests/files/tags/naglowek_podrozdzial/1.xml new file mode 100644 index 0000000..f0e14fd --- /dev/null +++ b/tests/files/tags/naglowek_podrozdzial/1.xml @@ -0,0 +1 @@ + numer-i/lub-tytuł-podrozdziału diff --git a/tests/files/tags/naglowek_rozdzial/1.expected.html b/tests/files/tags/naglowek_rozdzial/1.expected.html new file mode 100644 index 0000000..578edc1 --- /dev/null +++ b/tests/files/tags/naglowek_rozdzial/1.expected.html @@ -0,0 +1,12 @@ +
    + +

    +Bolesław PrusLalkaTom pierwszy +

    +

    I. Jak wygląda firma J. Mincel i S. Wokulski przez szkło butelek?

    +
    diff --git a/tests/files/tags/naglowek_rozdzial/1.xml b/tests/files/tags/naglowek_rozdzial/1.xml new file mode 100644 index 0000000..4ee02e5 --- /dev/null +++ b/tests/files/tags/naglowek_rozdzial/1.xml @@ -0,0 +1,6 @@ +Bolesław Prus +Lalka +Tom pierwszy + +I. Jak wygląda firma J. Mincel i S. Wokulski przez szkło butelek? + diff --git a/tests/files/tags/nazwa_utworu/1.expected.html b/tests/files/tags/nazwa_utworu/1.expected.html new file mode 100644 index 0000000..b89798a --- /dev/null +++ b/tests/files/tags/nazwa_utworu/1.expected.html @@ -0,0 +1 @@ +

    Anioł

    diff --git a/tests/files/tags/nazwa_utworu/1.xml b/tests/files/tags/nazwa_utworu/1.xml new file mode 100644 index 0000000..0627acf --- /dev/null +++ b/tests/files/tags/nazwa_utworu/1.xml @@ -0,0 +1 @@ +Anioł diff --git a/tests/files/tags/nota/1.expected.html b/tests/files/tags/nota/1.expected.html new file mode 100644 index 0000000..e68a4bc --- /dev/null +++ b/tests/files/tags/nota/1.expected.html @@ -0,0 +1,7 @@ +
    +

    +Henryk SienkiewiczLatarnik +

    +

    Opowiadanie to osnute jest na wypadku rzeczywistym, o którym w swoim czasie pisał J. Horain + w jednej ze swoich korespondencyj z Ameryki.

    +
    diff --git a/tests/files/tags/nota/1.xml b/tests/files/tags/nota/1.xml new file mode 100644 index 0000000..57991c6 --- /dev/null +++ b/tests/files/tags/nota/1.xml @@ -0,0 +1,5 @@ +Henryk Sienkiewicz +Latarnik + +Opowiadanie to osnute jest na wypadku rzeczywistym, o którym w swoim czasie pisał J. Horain + w jednej ze swoich korespondencyj z Ameryki. diff --git a/tests/files/tags/nota/2.expected.html b/tests/files/tags/nota/2.expected.html new file mode 100644 index 0000000..6006ef6 --- /dev/null +++ b/tests/files/tags/nota/2.expected.html @@ -0,0 +1,18 @@ +
    +
    +

    Spis treści

    +
      +III
    1. +
    +
    +

    III

    +
    +1
    Każdego z takich, jak ty, świat nie może
    +
    Od razu przyjąć na spokojne łoże,
    +
    I nie przyjmował nigdy, jak wiek wiekiem.
    +
    Bo glina w glinę wtapia się bez przerwy,
    +5
    Gdy sprzeczne ciała zbija się aż ćwiekiem
    +
    Później... lub pierwéj...
    +
    +

    Pisałem w Paryżu 1856 w styczniu.

    +
    diff --git a/tests/files/tags/nota/2.xml b/tests/files/tags/nota/2.xml new file mode 100644 index 0000000..efa9504 --- /dev/null +++ b/tests/files/tags/nota/2.xml @@ -0,0 +1,14 @@ + + +III + + +Każdego z takich, jak ty, świat nie może/ +Od razu przyjąć na spokojne łoże,/ +I nie przyjmował nigdy, jak wiek wiekiem./ +Bo glina w glinę wtapia się bez przerwy,/ +Gdy sprzeczne ciała zbija się aż ćwiekiem/ +Później... lub pierwéj... + + +Pisałem w Paryżu 1856 w styczniu. diff --git a/tests/files/tags/nota/3.expected.html b/tests/files/tags/nota/3.expected.html new file mode 100644 index 0000000..b7d62b4 --- /dev/null +++ b/tests/files/tags/nota/3.expected.html @@ -0,0 +1,8 @@ +
    +1

    Jego marzenie się nie spełniło: nie ożenił się, choć był już na to zupełnie zdecydowany, +gdy skończono oporządzać jego mieszkanie. [...] Rzecz dziwna, czym jest mundur dla takich ludzi.

    +

    Uwaga tłumacza. Drukowane obecnie w „Nowej Reformie” +Wspomnienia Sybiraka (pamiętniki Józefa Bogusławskiego) pozwalają +szczęśliwym trafem podać w całości nazwiska Polaków, o których mówi Dostojewski w swoich pamiętnikach, +oznaczając te nazwiska tylko pierwszymi literami, z dodaniem czasami końcówek. [...]

    +
    diff --git a/tests/files/tags/nota/3.xml b/tests/files/tags/nota/3.xml new file mode 100644 index 0000000..92e7980 --- /dev/null +++ b/tests/files/tags/nota/3.xml @@ -0,0 +1,9 @@ + + +Jego marzenie się nie spełniło: nie ożenił się, choć był już na to zupełnie zdecydowany, +gdy skończono oporządzać jego mieszkanie. [...] Rzecz dziwna, czym jest mundur dla takich ludzi. + +Uwaga tłumacza. Drukowane obecnie w ,,Nowej Reformie" +Wspomnienia Sybiraka (pamiętniki Józefa Bogusławskiego) pozwalają +szczęśliwym trafem podać w całości nazwiska Polaków, o których mówi Dostojewski w swoich pamiętnikach, +oznaczając te nazwiska tylko pierwszymi literami, z dodaniem czasami końcówek. [...] diff --git a/tests/files/tags/nota/4.expected.html b/tests/files/tags/nota/4.expected.html new file mode 100644 index 0000000..ec32394 --- /dev/null +++ b/tests/files/tags/nota/4.expected.html @@ -0,0 +1,12 @@ +
    +
    +

    Spis treści

    +
      +Gospodarstwo
    1. +
    +
    +

    Gospodarstwo

    +

    Powrót panicza — Spotkanie się pierwsze w pokoiku, drugie u stołu — Ważna Sędziego +nauka o grzeczności — Podkomorzego uwagi polityczne nad modami — Początek sporu o Kusego i Sokoła +— Żale Wojskiego — Ostatni Woźny Trybunału — Rzut oka na ówczesny stan polityczny Litwy i Europy

    +
    diff --git a/tests/files/tags/nota/4.xml b/tests/files/tags/nota/4.xml new file mode 100644 index 0000000..56ab06f --- /dev/null +++ b/tests/files/tags/nota/4.xml @@ -0,0 +1,7 @@ + + +Gospodarstwo + +Powrót panicza --- Spotkanie się pierwsze w pokoiku, drugie u stołu --- Ważna Sędziego +nauka o grzeczności --- Podkomorzego uwagi polityczne nad modami --- Początek sporu o Kusego i Sokoła +--- Żale Wojskiego --- Ostatni Woźny Trybunału --- Rzut oka na ówczesny stan polityczny Litwy i Europy diff --git a/tests/files/tags/nota/5.expected.html b/tests/files/tags/nota/5.expected.html new file mode 100644 index 0000000..dadf5f6 --- /dev/null +++ b/tests/files/tags/nota/5.expected.html @@ -0,0 +1,5 @@ +
    +

    II

    +

    Moje wypadki • Ognisko w wąwozie • Uczta • Opowiadania skwatera • Nocleg • Głosy nocne +• Niespokojne sny • Ranek • Polowanie z zasadzki • Pierwszy jeleń

    +
    diff --git a/tests/files/tags/nota/5.xml b/tests/files/tags/nota/5.xml new file mode 100644 index 0000000..94747d3 --- /dev/null +++ b/tests/files/tags/nota/5.xml @@ -0,0 +1,4 @@ +II + +Moje wypadki • Ognisko w wąwozie • Uczta • Opowiadania skwatera • Nocleg • Głosy nocne +• Niespokojne sny • Ranek • Polowanie z zasadzki • Pierwszy jeleń diff --git a/tests/files/tags/nota/6.expected.html b/tests/files/tags/nota/6.expected.html new file mode 100644 index 0000000..b0465e4 --- /dev/null +++ b/tests/files/tags/nota/6.expected.html @@ -0,0 +1,8 @@ +
    +1

    Oto rozdziały dwudziesty piąty, szósty i siódmy przygotowują nadchodzącą chwilę.

    +

    Idea dobra zaczyna świecić

    +2

    Już Arystofanes tłumaczy Erosa, który dwie płci wiąże, stwarzając mit, dając koncepcję +„dążenia do jedności”. Dopiero teraz popęd płciowy wystąpi w jasnym, boskim świetle, jako +nieświadome dążenie do nieśmiertelności. Pokaże się, że istoty żywe dlatego tylko zapłodnienia +pragną, że zapłodnienie uczestniczy jakoś w wielkiej idei „nieśmiertelnego dobra”.

    +
    diff --git a/tests/files/tags/nota/6.xml b/tests/files/tags/nota/6.xml new file mode 100644 index 0000000..63c88ae --- /dev/null +++ b/tests/files/tags/nota/6.xml @@ -0,0 +1,9 @@ + + +Oto rozdziały dwudziesty piąty, szósty i siódmy przygotowują nadchodzącą chwilę. + +Idea dobra zaczyna świecić +Już Arystofanes tłumaczy Erosa, który dwie płci wiąże, stwarzając mit, dając koncepcję +,,dążenia do jedności". Dopiero teraz popęd płciowy wystąpi w jasnym, boskim świetle, jako +nieświadome dążenie do nieśmiertelności. Pokaże się, że istoty żywe dlatego tylko zapłodnienia +pragną, że zapłodnienie uczestniczy jakoś w wielkiej idei ,,nieśmiertelnego dobra". diff --git a/tests/files/tags/numeracja/1.expected.html b/tests/files/tags/numeracja/1.expected.html new file mode 100644 index 0000000..7ae68bb --- /dev/null +++ b/tests/files/tags/numeracja/1.expected.html @@ -0,0 +1,30 @@ +
    +
    +1
    Jednych tam śmierć porwała kres życiu znacząca,
    +
    Drugim z dala od ludzi Zeus życie rozkoszy
    +
    Dał pełne i umieścił ich u ziemi końca,
    +
    Gdzie żadna troska w sercu spokoju nie płoszy,
    +5
    W Krainie Szczęścia nad pienistym Oceanem,
    +100
    Z dala od bogów; Kronos jest nad nimi panem,
    +
    [Zwolniony z pęt przez bogów i ludzi rodzica.
    +
    Zeus im udzielił wielkiej czci, chwałą zaszczyca
    +
    I wyniósł ich jak żadne w porównaniu z niemi
    +
    Plemię z tych, które żyły na wszechpłodnej ziemi.]
    +105
    Cni bohaterzy! Trzykroć w roku owoc wszelki,
    +
    Jak miód słodki, od ziemi biorą żywicielki.
    +
    +
    +
    Gdy masz przejść w bród przez piękne fale wiecznej rzeki,
    +
    Módl się wprzód, umyj ręce i spójrz w prąd daleki.
    +740
    Tym, co wchodzą do rzeki, nie mocząc rąk, prości,
    +
    Bogowie odpłacają cierpieniem w przyszłości.
    +
    Gdy bogom uroczyste obiaty się palą,
    +
    +
    +1
    Pilnie strzeż się na bliźnich mieść potwarzy brzemię.
    +
    Mały zachód, trud lekki popuścić jej wodze,
    +
    Lecz ciężko dźwigać, trudno ją zrzucić na ziemię.
    +
    Nigdy potwarz, jeżeli ją uprawia mnóstwo,
    +5
    Nie ginie całkiem; to też w swym rodzaju bóstwo.
    +
    +
    diff --git a/tests/files/tags/numeracja/1.xml b/tests/files/tags/numeracja/1.xml new file mode 100644 index 0000000..14d29c4 --- /dev/null +++ b/tests/files/tags/numeracja/1.xml @@ -0,0 +1,32 @@ + +Jednych tam śmierć porwała kres życiu znacząca,/ +Drugim z dala od ludzi Zeus życie rozkoszy/ +Dał pełne i umieścił ich u ziemi końca,/ +Gdzie żadna troska w sercu spokoju nie płoszy,/ +W Krainie Szczęścia nad pienistym Oceanem,/ +Z dala od bogów; Kronos jest nad nimi panem,/ +[Zwolniony z pęt przez bogów i ludzi rodzica./ +Zeus im udzielił wielkiej czci, chwałą zaszczyca/ +I wyniósł ich jak żadne w porównaniu z niemi/ +Plemię z tych, które żyły na wszechpłodnej ziemi.]/ +Cni bohaterzy! Trzykroć w roku owoc wszelki,/ +Jak miód słodki, od ziemi biorą żywicielki. + + + + + +Gdy masz przejść w bród przez piękne fale wiecznej rzeki,/ +Módl się wprzód, umyj ręce i spójrz w prąd daleki./ +Tym, co wchodzą do rzeki, nie mocząc rąk, prości,/ +Bogowie odpłacają cierpieniem w przyszłości./ +Gdy bogom uroczyste obiaty się palą, + + + + +Pilnie strzeż się na bliźnich mieść potwarzy brzemię./ +Mały zachód, trud lekki popuścić jej wodze,/ +Lecz ciężko dźwigać, trudno ją zrzucić na ziemię./ +Nigdy potwarz, jeżeli ją uprawia mnóstwo,/ +Nie ginie całkiem; to też w swym rodzaju bóstwo. diff --git a/tests/files/tags/osoba/1.expected.html b/tests/files/tags/osoba/1.expected.html new file mode 100644 index 0000000..50a9b9c --- /dev/null +++ b/tests/files/tags/osoba/1.expected.html @@ -0,0 +1,23 @@ +
    +
    +

    Spis treści

    +
      +AKT PIERWSZY
      1. +SCENA PIERWSZA
      2. +
    1. +
    +
    +

    AKT PIERWSZY

    +
    +Pokój w zamku +Cześnika, +drzwi na prawo, lewo i w środku, stoły, krzesła etc., gitara angielska na ścianie. +
    +

    SCENA PIERWSZA

    +
    + +Cześnik, +Dyndalski + +
    +
    diff --git a/tests/files/tags/osoba/1.xml b/tests/files/tags/osoba/1.xml new file mode 100644 index 0000000..98bf0e0 --- /dev/null +++ b/tests/files/tags/osoba/1.xml @@ -0,0 +1,16 @@ +AKT PIERWSZY + + +Pokój w zamku +Cześnika, +drzwi na prawo, lewo i w środku, stoły, krzesła etc., gitara angielska na ścianie. + + +SCENA PIERWSZA + + + +Cześnik, +Dyndalski + + diff --git a/tests/files/tags/pa/1.expected.html b/tests/files/tags/pa/1.expected.html new file mode 100644 index 0000000..f74cb3f --- /dev/null +++ b/tests/files/tags/pa/1.expected.html @@ -0,0 +1,9 @@ +
    +1

    Bieży[1].

    +
    +

    Przypisy

    +
    +[1]

    bieży — biegnie. [przypis autorski]

    +
    +
    +
    diff --git a/tests/files/tags/pa/1.xml b/tests/files/tags/pa/1.xml new file mode 100644 index 0000000..ebe4b29 --- /dev/null +++ b/tests/files/tags/pa/1.xml @@ -0,0 +1,3 @@ + + Bieżybieży --- biegnie.. + diff --git a/tests/files/tags/pe/1.expected.html b/tests/files/tags/pe/1.expected.html new file mode 100644 index 0000000..777d900 --- /dev/null +++ b/tests/files/tags/pe/1.expected.html @@ -0,0 +1,9 @@ +
    +1

    Bieży[1].

    +
    +

    Przypisy

    +
    +[1]

    bieży — biegnie. [przypis edytorski]

    +
    +
    +
    diff --git a/tests/files/tags/pe/1.xml b/tests/files/tags/pe/1.xml new file mode 100644 index 0000000..f28f30e --- /dev/null +++ b/tests/files/tags/pe/1.xml @@ -0,0 +1,3 @@ + + Bieżybieży --- biegnie.. + diff --git a/tests/files/tags/pe/2.expected.html b/tests/files/tags/pe/2.expected.html new file mode 100644 index 0000000..e30725e --- /dev/null +++ b/tests/files/tags/pe/2.expected.html @@ -0,0 +1,12 @@ +
    +1

    Bieży[1].

    +
    +

    Przypisy

    +
    +[1]

    +

    bieży — biegnie.

    +

    Drugi akapit przypisu.

    + [przypis edytorski]

    +
    +
    +
    diff --git a/tests/files/tags/pe/2.xml b/tests/files/tags/pe/2.xml new file mode 100644 index 0000000..ab00e06 --- /dev/null +++ b/tests/files/tags/pe/2.xml @@ -0,0 +1,6 @@ + + Bieży + bieży --- biegnie. + Drugi akapit przypisu. + . + diff --git a/tests/files/tags/podtytul/1.expected.html b/tests/files/tags/podtytul/1.expected.html new file mode 100644 index 0000000..2fdf222 --- /dev/null +++ b/tests/files/tags/podtytul/1.expected.html @@ -0,0 +1,3 @@ +

    +Daniel DefoeRobinson CrusoeJego życia losy, doświadczenia i przypadki +

    diff --git a/tests/files/tags/podtytul/1.xml b/tests/files/tags/podtytul/1.xml new file mode 100644 index 0000000..55415f3 --- /dev/null +++ b/tests/files/tags/podtytul/1.xml @@ -0,0 +1,4 @@ +Daniel Defoe +Robinson Crusoe + +Jego życia losy, doświadczenia i przypadki diff --git a/tests/files/tags/poezja_cyt/1.expected.html b/tests/files/tags/poezja_cyt/1.expected.html new file mode 100644 index 0000000..b0d195b --- /dev/null +++ b/tests/files/tags/poezja_cyt/1.expected.html @@ -0,0 +1,4 @@ +
    +1
    Tymczasem przenoś duszę moją utęsknioną
    +
    Do tych pagórków leśnych, do tych łąk zielonych...
    +
    diff --git a/tests/files/tags/poezja_cyt/1.xml b/tests/files/tags/poezja_cyt/1.xml new file mode 100644 index 0000000..e003954 --- /dev/null +++ b/tests/files/tags/poezja_cyt/1.xml @@ -0,0 +1,6 @@ + + +Tymczasem przenoś duszę moją utęsknioną/ +Do tych pagórków leśnych, do tych łąk zielonych... + + diff --git a/tests/files/tags/pr/1.expected.html b/tests/files/tags/pr/1.expected.html new file mode 100644 index 0000000..72ec98a --- /dev/null +++ b/tests/files/tags/pr/1.expected.html @@ -0,0 +1,9 @@ +
    +1

    Bieży[1].

    +
    +

    Przypisy

    +
    +[1]

    bieży — biegnie. [przypis redakcyjny]

    +
    +
    +
    diff --git a/tests/files/tags/pr/1.xml b/tests/files/tags/pr/1.xml new file mode 100644 index 0000000..f111c8b --- /dev/null +++ b/tests/files/tags/pr/1.xml @@ -0,0 +1,3 @@ + + Bieżybieży --- biegnie.. + diff --git a/tests/files/tags/pt/1.expected.html b/tests/files/tags/pt/1.expected.html new file mode 100644 index 0000000..0cbd428 --- /dev/null +++ b/tests/files/tags/pt/1.expected.html @@ -0,0 +1,9 @@ +
    +1

    Bieży[1].

    +
    +

    Przypisy

    +
    +[1]

    bieży — biegnie. [przypis tłumacza]

    +
    +
    +
    diff --git a/tests/files/tags/pt/1.xml b/tests/files/tags/pt/1.xml new file mode 100644 index 0000000..c832b38 --- /dev/null +++ b/tests/files/tags/pt/1.xml @@ -0,0 +1,3 @@ + + Bieżybieży --- biegnie.. + diff --git a/tests/files/tags/ref/1.expected.html b/tests/files/tags/ref/1.expected.html new file mode 100644 index 0000000..85c374a --- /dev/null +++ b/tests/files/tags/ref/1.expected.html @@ -0,0 +1,3 @@ +
    +1

    W roku 1872 dom pod numerem 7 przy Saville Row, Burlington Gardens, w którym w roku 1814 zmarł Sheridan, był zamieszkany przez Phileasa Fogga, członka londyńskiego klubu „Reforma”, osobistość wybitną i wielce oryginalną.

    +
    diff --git a/tests/files/tags/ref/1.xml b/tests/files/tags/ref/1.xml new file mode 100644 index 0000000..6d46efe --- /dev/null +++ b/tests/files/tags/ref/1.xml @@ -0,0 +1 @@ +W roku 1872 dom pod numerem 7 przy Saville Row, Burlington Gardens, w którym w roku 1814 zmarł Sheridan, był zamieszkany przez Phileasa Fogga, członka londyńskiego klubu ,,Reforma", osobistość wybitną i wielce oryginalną. diff --git a/tests/files/tags/rownolegle/1.expected.html b/tests/files/tags/rownolegle/1.expected.html new file mode 100644 index 0000000..36d9021 --- /dev/null +++ b/tests/files/tags/rownolegle/1.expected.html @@ -0,0 +1,13 @@ +
    +
    +1

    Treść

    +
    +
    +
    +2

    Treść

    +
    +
    +3

    Treść

    +
    +
    +
    diff --git a/tests/files/tags/rownolegle/1.xml b/tests/files/tags/rownolegle/1.xml new file mode 100644 index 0000000..8775145 --- /dev/null +++ b/tests/files/tags/rownolegle/1.xml @@ -0,0 +1,16 @@ + + + + Treść + + + + + Treść + + + Treść + + + + diff --git a/tests/files/tags/sekcja_asterysk/1.expected.html b/tests/files/tags/sekcja_asterysk/1.expected.html new file mode 100644 index 0000000..d1d86b7 --- /dev/null +++ b/tests/files/tags/sekcja_asterysk/1.expected.html @@ -0,0 +1,5 @@ +
    +1

    Tekst

    +

    *

    +2

    Tekst

    +
    diff --git a/tests/files/tags/sekcja_asterysk/1.xml b/tests/files/tags/sekcja_asterysk/1.xml new file mode 100644 index 0000000..c7b34ae --- /dev/null +++ b/tests/files/tags/sekcja_asterysk/1.xml @@ -0,0 +1,5 @@ +Tekst + + + +Tekst diff --git a/tests/files/tags/sekcja_swiatlo/1.expected.html b/tests/files/tags/sekcja_swiatlo/1.expected.html new file mode 100644 index 0000000..6985524 --- /dev/null +++ b/tests/files/tags/sekcja_swiatlo/1.expected.html @@ -0,0 +1,5 @@ +
    +1

    Tekst

    +
    +2

    Tekst

    +
    diff --git a/tests/files/tags/sekcja_swiatlo/1.xml b/tests/files/tags/sekcja_swiatlo/1.xml new file mode 100644 index 0000000..34ac256 --- /dev/null +++ b/tests/files/tags/sekcja_swiatlo/1.xml @@ -0,0 +1,5 @@ +Tekst + + + +Tekst diff --git a/tests/files/tags/separator_linia/1.expected.html b/tests/files/tags/separator_linia/1.expected.html new file mode 100644 index 0000000..4f54cff --- /dev/null +++ b/tests/files/tags/separator_linia/1.expected.html @@ -0,0 +1,5 @@ +
    +1

    Tekst

    +
    +2

    Tekst

    +
    diff --git a/tests/files/tags/separator_linia/1.xml b/tests/files/tags/separator_linia/1.xml new file mode 100644 index 0000000..4c05f5e --- /dev/null +++ b/tests/files/tags/separator_linia/1.xml @@ -0,0 +1,5 @@ +Tekst + + + +Tekst diff --git a/tests/files/tags/slowo_obce/1.expected.html b/tests/files/tags/slowo_obce/1.expected.html new file mode 100644 index 0000000..8fa6808 --- /dev/null +++ b/tests/files/tags/slowo_obce/1.expected.html @@ -0,0 +1,3 @@ +
    +1

    Na czwarty dzień przywiózł mu stójka z osłowickiej apteki diachylum; Zołzikiewicz rozsmarował na płatek...

    +
    diff --git a/tests/files/tags/slowo_obce/1.xml b/tests/files/tags/slowo_obce/1.xml new file mode 100644 index 0000000..8e99a29 --- /dev/null +++ b/tests/files/tags/slowo_obce/1.xml @@ -0,0 +1,3 @@ + +Na czwarty dzień przywiózł mu stójka z osłowickiej apteki diachylum; Zołzikiewicz rozsmarował na płatek... + diff --git a/tests/files/tags/srodtytul/1.expected.html b/tests/files/tags/srodtytul/1.expected.html new file mode 100644 index 0000000..291f17f --- /dev/null +++ b/tests/files/tags/srodtytul/1.expected.html @@ -0,0 +1,9 @@ +
    +
    +

    Spis treści

    +
      +śródtytuł
    1. +
    +
    +

    śródtytuł

    +
    diff --git a/tests/files/tags/srodtytul/1.xml b/tests/files/tags/srodtytul/1.xml new file mode 100644 index 0000000..8132adf --- /dev/null +++ b/tests/files/tags/srodtytul/1.xml @@ -0,0 +1 @@ + śródtytuł diff --git a/tests/files/tags/strofa/1.expected.html b/tests/files/tags/strofa/1.expected.html new file mode 100644 index 0000000..fb5cb9a --- /dev/null +++ b/tests/files/tags/strofa/1.expected.html @@ -0,0 +1,13 @@ +
    +

    +Mikołaj Sęp SzarzyńskiDo Zosie +

    +
    +1
    Będę się zawsze dziwował twojej pikności:
    +
    Nie szkodzi wiernej dalekość miłości;
    +
    Bo, gdzie ciałem nie mogę być, tam myślą będę,
    +
    A pierwej siebie, niż ciebie zabędę;
    +5
    A dotąd się serce me smęcić nie przestanie,
    +
    Aż cię oglądam, me wdzięczne kochanie.
    +
    +
    diff --git a/tests/files/tags/strofa/1.xml b/tests/files/tags/strofa/1.xml new file mode 100644 index 0000000..9310b33 --- /dev/null +++ b/tests/files/tags/strofa/1.xml @@ -0,0 +1,10 @@ +Mikołaj Sęp Szarzyński +Do Zosie + +Będę się zawsze dziwował twojej pikności:/ +Nie szkodzi wiernej dalekość miłości;/ +Bo, gdzie ciałem nie mogę być, tam myślą będę,/ +A pierwej siebie, niż ciebie zabędę;/ +A dotąd się serce me smęcić nie przestanie,/ +Aż cię oglądam, me wdzięczne kochanie. + diff --git a/tests/files/tags/tab/1.expected.html b/tests/files/tags/tab/1.expected.html new file mode 100644 index 0000000..e2afe7d --- /dev/null +++ b/tests/files/tags/tab/1.expected.html @@ -0,0 +1,21 @@ +
    +1
    AB
    +
    A1
    +
    A2
    +
    A3
    +5
    A4
    +
    A5
    +
    A6
    +
    A1em
    +
    A2em
    +10
    A3em
    +
    A4em
    +
    A5em
    +
    A6em
    +
    +A* +
    +15
    +Rozszerzony tabulator wewnątrzwyróżnienia +
    +
    diff --git a/tests/files/tags/tab/1.xml b/tests/files/tags/tab/1.xml new file mode 100644 index 0000000..bd2dc46 --- /dev/null +++ b/tests/files/tags/tab/1.xml @@ -0,0 +1,17 @@ + + AB/ + A1/ + A2/ + A3/ + A4/ + A5/ + A6/ + A1em/ + A2em/ + A3em/ + A4em/ + A5em/ + A6em/ + A*/ + Rozszerzony tabulator wewnątrzwyróżnienia + diff --git a/tests/files/tags/tabela/1.expected.html b/tests/files/tags/tabela/1.expected.html new file mode 100644 index 0000000..fe9ef5f --- /dev/null +++ b/tests/files/tags/tabela/1.expected.html @@ -0,0 +1,22 @@ +
    + + + + + + + + + +
    ab
    cd
    + + + + + + + + + +
    ab
    cd
    +
    diff --git a/tests/files/tags/tabela/1.xml b/tests/files/tags/tabela/1.xml new file mode 100644 index 0000000..5e8f12b --- /dev/null +++ b/tests/files/tags/tabela/1.xml @@ -0,0 +1,21 @@ + + + a + b + + + c + d + + + + + + a + b + + + c + d + + diff --git a/tests/files/tags/tytul_dziela/1.expected.html b/tests/files/tags/tytul_dziela/1.expected.html new file mode 100644 index 0000000..364942d --- /dev/null +++ b/tests/files/tags/tytul_dziela/1.expected.html @@ -0,0 +1,8 @@ +
    +1

    Przeczytałem wczoraj + + Kilka uwag o „Hamlecie” + Szekspira + + pióra...

    +
    diff --git a/tests/files/tags/tytul_dziela/1.xml b/tests/files/tags/tytul_dziela/1.xml new file mode 100644 index 0000000..3b79afd --- /dev/null +++ b/tests/files/tags/tytul_dziela/1.xml @@ -0,0 +1,9 @@ + + Przeczytałem wczoraj + + Kilka uwag o + Hamlecie + Szekspira + + pióra... + diff --git a/tests/files/tags/tytul_dziela/2.expected.html b/tests/files/tags/tytul_dziela/2.expected.html new file mode 100644 index 0000000..b744afd --- /dev/null +++ b/tests/files/tags/tytul_dziela/2.expected.html @@ -0,0 +1,3 @@ +
    +1

    Belzebub (z hebr.) — w Nowym Testamencie pan piekieł i przywódca złych duchów. W utworze Krasińskiego ma on być twórcą „spróchniałego obrazu” raju, który to obraz — niby dekorację teatralną — złe duchy przechowują w sklepach, czyli podziemiach (staropolskie: sklep — piwnica, loch, podziemie). Wokół interpretacji obrazu Edenu rozwinęła się polemika między A. Łuckim a Z. Niemojewską–Gruszczyńską (A. Łucki, Obraz Edenu w „Nie–Boskiej komedii”, „Ruch literacki”, nr 3, s.65–67; Z. Niemojewska–Gruszczyńska, W sprawie obrazu Edenu w „Nie–Boskiej komedii”, tamże, nr 5, s. 133–135; A. Łucki, Jeszcze w sprawie obrazu Edenu w „Nie–Boskiej komedii”, tamże, nr 6, s.191–192). Kleiner sądzi, że obraz Edenu to przyroda „zespolona z jakimiś utopijnymi marzeniami”, „że plan pierwotny był odmienny”, przyroda „miała być narzędziem szatana”, kuszącego wyobraźnię poety. Za tą interpretacją idzie też wyd. Libery i Sawrymowicza. Według M. Janion interpretacja Edenu jako jednej z trzech wizji–kuszeń może być dwojaka. Po pierwsze można uznać, że Eden stanowi tu synonim natury, tak jak rozumieli ją romantycy: to raj utracony, stan naturalnej szczęśliwości, przeciwieństwo życia w cywilizacji, prosty i harmonijny żywot. Ale można rozumieć ów symboliczny Eden jako oświeceniowy „stan naturalny” człowieka związany z filozoficzną utopią XVIII–wiecznych racjonalistów. Wtedy pokusę szatańską łączyć należy z obrazem przyszłego szczęścia ludzkości, jaką roztacza Pankracy w rozmowie z hrabią Henrykiem.

    +
    diff --git a/tests/files/tags/tytul_dziela/2.xml b/tests/files/tags/tytul_dziela/2.xml new file mode 100644 index 0000000..ce17d5c --- /dev/null +++ b/tests/files/tags/tytul_dziela/2.xml @@ -0,0 +1,3 @@ + + Belzebub (z hebr.) --- w Nowym Testamencie pan piekieł i przywódca złych duchów. W utworze Krasińskiego ma on być twórcą ,,spróchniałego obrazu" raju, który to obraz --- niby dekorację teatralną --- złe duchy przechowują w sklepach, czyli podziemiach (staropolskie: sklep --- piwnica, loch, podziemie). Wokół interpretacji obrazu Edenu rozwinęła się polemika między A. Łuckim a Z. Niemojewską--Gruszczyńską (A. Łucki, Obraz Edenu w Nie--Boskiej komedii, ,,Ruch literacki", nr 3, s.65--67; Z. Niemojewska--Gruszczyńska, W sprawie obrazu Edenu w Nie--Boskiej komedii, tamże, nr 5, s. 133--135; A. Łucki, Jeszcze w sprawie obrazu Edenu w Nie--Boskiej komedii, tamże, nr 6, s.191--192). Kleiner sądzi, że obraz Edenu to przyroda ,,zespolona z jakimiś utopijnymi marzeniami", ,,że plan pierwotny był odmienny", przyroda ,,miała być narzędziem szatana", kuszącego wyobraźnię poety. Za tą interpretacją idzie też wyd. Libery i Sawrymowicza. Według M. Janion interpretacja Edenu jako jednej z trzech wizji--kuszeń może być dwojaka. Po pierwsze można uznać, że Eden stanowi tu synonim natury, tak jak rozumieli ją romantycy: to raj utracony, stan naturalnej szczęśliwości, przeciwieństwo życia w cywilizacji, prosty i harmonijny żywot. Ale można rozumieć ów symboliczny Eden jako oświeceniowy ,,stan naturalny" człowieka związany z filozoficzną utopią XVIII--wiecznych racjonalistów. Wtedy pokusę szatańską łączyć należy z obrazem przyszłego szczęścia ludzkości, jaką roztacza Pankracy w rozmowie z hrabią Henrykiem. + diff --git a/tests/files/tags/wers_cd/1.expected.html b/tests/files/tags/wers_cd/1.expected.html new file mode 100644 index 0000000..c0aea62 --- /dev/null +++ b/tests/files/tags/wers_cd/1.expected.html @@ -0,0 +1,17 @@ +
    +

    MARYNA

    +
    +1
    Więc?
    + +
    +

    POETA

    +
    +
    Sztuka dla sztuki.
    +
    +

    MARYNA

    +
    +
    Zawrót głowy, wielka chwała;
    +
    niech pan sztuki płata różne,
    +5
    bylebym ja spokój miała.
    +
    +
    diff --git a/tests/files/tags/wers_cd/1.xml b/tests/files/tags/wers_cd/1.xml new file mode 100644 index 0000000..c64c14c --- /dev/null +++ b/tests/files/tags/wers_cd/1.xml @@ -0,0 +1,23 @@ +MARYNA + + + + Więc? + + + + +POETA + + + Sztuka dla sztuki. + + + +MARYNA + +Zawrót głowy, wielka chwała;/ +niech pan sztuki płata różne,/ +bylebym ja spokój miała. + + diff --git a/tests/files/tags/wers_do_prawej/1.expected.html b/tests/files/tags/wers_do_prawej/1.expected.html new file mode 100644 index 0000000..922ce4a --- /dev/null +++ b/tests/files/tags/wers_do_prawej/1.expected.html @@ -0,0 +1,8 @@ +
    +1
    Anioł ognisty — mój anioł lewy
    +
    Poruszył dawną miłości strunę.
    +
    Z tobą! o! z tobą, gdzie białe mewy,
    +
    Z tobą w podśnieżną sybirską trunę,
    +5
    Gdzie wiatry wyją tak jak hyjeny,
    +
    Tam, gdzie ty pasasz na grobach reny.
    +
    diff --git a/tests/files/tags/wers_do_prawej/1.xml b/tests/files/tags/wers_do_prawej/1.xml new file mode 100644 index 0000000..0a32e1e --- /dev/null +++ b/tests/files/tags/wers_do_prawej/1.xml @@ -0,0 +1,7 @@ +Anioł ognisty --- mój anioł lewy/ +Poruszył dawną miłości strunę./ +Z tobą! o! z tobą, gdzie białe mewy,/ +Z tobą w podśnieżną sybirską trunę,/ +Gdzie wiatry wyją tak jak hyjeny,/ +Tam, gdzie ty pasasz na grobach reny. + diff --git a/tests/files/tags/wers_wciety/1.expected.html b/tests/files/tags/wers_wciety/1.expected.html new file mode 100644 index 0000000..0ee7c74 --- /dev/null +++ b/tests/files/tags/wers_wciety/1.expected.html @@ -0,0 +1,13 @@ +
    +

    +Julisz SłowackiAnioł ognisty — mój anioł lewy... +

    +
    +1
    Anioł ognisty — mój anioł lewy
    +
    Poruszył dawną miłości strunę.
    +
    Z tobą! o! z tobą, gdzie białe mewy,
    +
    Z tobą w podśnieżną sybirską trunę,
    +5
    Gdzie wiatry wyją tak jak hyjeny,
    +
    Tam, gdzie ty pasasz na grobach reny.
    +
    +
    diff --git a/tests/files/tags/wers_wciety/1.xml b/tests/files/tags/wers_wciety/1.xml new file mode 100644 index 0000000..db6c80d --- /dev/null +++ b/tests/files/tags/wers_wciety/1.xml @@ -0,0 +1,13 @@ +Julisz Słowacki +Anioł ognisty --- mój anioł lewy... +Anioł ognisty --- mój anioł lewy/ + +Poruszył dawną miłości strunę./ + +Z tobą! o! z tobą, gdzie białe mewy,/ + +Z tobą w podśnieżną sybirską trunę,/ + +Gdzie wiatry wyją tak jak hyjeny,/ +Tam, gdzie ty pasasz na grobach reny. + diff --git a/tests/files/tags/wers_wciety/2.expected.html b/tests/files/tags/wers_wciety/2.expected.html new file mode 100644 index 0000000..85b8e22 --- /dev/null +++ b/tests/files/tags/wers_wciety/2.expected.html @@ -0,0 +1,8 @@ +
    1
    zwykły
    +
    wcięty
    +
    wcięty 1
    +
    wcięty 2
    + 5
    wcięty 25
    +
    akapitowy
    +
    środek
    +
    do prawej
    diff --git a/tests/files/tags/wers_wciety/2.xml b/tests/files/tags/wers_wciety/2.xml new file mode 100644 index 0000000..c31d2cb --- /dev/null +++ b/tests/files/tags/wers_wciety/2.xml @@ -0,0 +1,10 @@ + + zwykły + wcięty + wcięty 1 + wcięty 2 + wcięty 25 + akapitowy + środek + do prawej + diff --git a/tests/files/tags/wieksze_odstepy/1.expected.html b/tests/files/tags/wieksze_odstepy/1.expected.html new file mode 100644 index 0000000..0ad94e4 --- /dev/null +++ b/tests/files/tags/wieksze_odstepy/1.expected.html @@ -0,0 +1,3 @@ +
    +1

    tekst tekst tekst

    +
    diff --git a/tests/files/tags/wieksze_odstepy/1.xml b/tests/files/tags/wieksze_odstepy/1.xml new file mode 100644 index 0000000..c647957 --- /dev/null +++ b/tests/files/tags/wieksze_odstepy/1.xml @@ -0,0 +1,3 @@ + + tekst tekst tekst + diff --git a/tests/files/tags/www/1.expected.html b/tests/files/tags/www/1.expected.html new file mode 100644 index 0000000..9b44ed6 --- /dev/null +++ b/tests/files/tags/www/1.expected.html @@ -0,0 +1,4 @@ + diff --git a/tests/files/tags/www/1.xml b/tests/files/tags/www/1.xml new file mode 100644 index 0000000..36c0360 --- /dev/null +++ b/tests/files/tags/www/1.xml @@ -0,0 +1,4 @@ + + Adres: + https://wolnelektury.pl + diff --git a/tests/files/tags/wyroznienie/1.expected.html b/tests/files/tags/wyroznienie/1.expected.html new file mode 100644 index 0000000..65cffe3 --- /dev/null +++ b/tests/files/tags/wyroznienie/1.expected.html @@ -0,0 +1,9 @@ +
    +1
    Byłem u Ciebie w te dni przedostatnie
    +
    Niedocieczonego wątku — —
    +
    — Pełne jak mit,
    +
    Blade jak świt,
    +5
    — Gdy życia koniec szepce do początku:
    +
    +„Nie stargam cię ja — nie! — Ja, u-wydatnię!...”
    +
    diff --git a/tests/files/tags/wyroznienie/1.xml b/tests/files/tags/wyroznienie/1.xml new file mode 100644 index 0000000..243ae6a --- /dev/null +++ b/tests/files/tags/wyroznienie/1.xml @@ -0,0 +1,9 @@ + +Byłem u Ciebie w te dni przedostatnie/ +Niedocieczonego wątku --- ---/ +--- Pełne jak mit,/ +Blade jak świt,/ +--- Gdy życia koniec szepce do początku:/ + +,,Nie stargam cię ja --- nie! --- Ja, u-wydatnię!..." + diff --git a/tests/files/tags/wywiad_pyt/1.expected.html b/tests/files/tags/wywiad_pyt/1.expected.html new file mode 100644 index 0000000..e8b700d --- /dev/null +++ b/tests/files/tags/wywiad_pyt/1.expected.html @@ -0,0 +1,4 @@ +
    +1

    blok akapitów pytania

    +2

    blok akapitów odpowiedzi

    +
    diff --git a/tests/files/tags/wywiad_pyt/1.xml b/tests/files/tags/wywiad_pyt/1.xml new file mode 100644 index 0000000..aa74999 --- /dev/null +++ b/tests/files/tags/wywiad_pyt/1.xml @@ -0,0 +1,3 @@ +blok akapitów pytania + +blok akapitów odpowiedzi diff --git a/tests/files/tags/zastepnik_wersu/1.expected.html b/tests/files/tags/zastepnik_wersu/1.expected.html new file mode 100644 index 0000000..cd767f2 --- /dev/null +++ b/tests/files/tags/zastepnik_wersu/1.expected.html @@ -0,0 +1,8 @@ +
    +1
    I powleczem korowód, smęcąc ujęte snem grody,
    +
    W bramy bijąc urnami, gwizdając w szczerby toporów,
    +
    Aż się mury Jerycha porozwalają jak kłody,
    +
    Serca zmdlałe ocucą, pleśń z oczu zgarną narody.
    +5
    . . . . . . . . . . . . . . . .
    +
    Dalej — dalej — —
    +
    diff --git a/tests/files/tags/zastepnik_wersu/1.xml b/tests/files/tags/zastepnik_wersu/1.xml new file mode 100644 index 0000000..716699a --- /dev/null +++ b/tests/files/tags/zastepnik_wersu/1.xml @@ -0,0 +1,10 @@ + +I powleczem korowód, smęcąc ujęte snem grody,/ +W bramy bijąc urnami, gwizdając w szczerby toporów,/ +Aż się mury Jerycha porozwalają jak kłody,/ +Serca zmdlałe ocucą, pleśń z oczu zgarną narody./ + +. . . . . . . . . . . . . . . ./ + +Dalej --- dalej --- --- + diff --git a/tests/files/text/abstrakt.expected.html b/tests/files/text/abstrakt.expected.html new file mode 100644 index 0000000..94c33b6 --- /dev/null +++ b/tests/files/text/abstrakt.expected.html @@ -0,0 +1,3 @@ +
    +

    Przygody Tomka Sawyera to najsłynniejsza powieść dla młodzieży autorstwa amerykańskiego pisarza Marka Twaina.

    +
    diff --git a/tests/files/text/abstrakt.xml b/tests/files/text/abstrakt.xml index 7a468a1..27d3cd5 100644 --- a/tests/files/text/abstrakt.xml +++ b/tests/files/text/abstrakt.xml @@ -1,6 +1,7 @@ - - - - + + + Przygody Tomka Sawyera to najsłynniejsza powieść dla młodzieży autorstwa amerykańskiego pisarza Marka Twaina. + + diff --git a/tests/files/text/asnyk_miedzy_nami_expected.html b/tests/files/text/asnyk_miedzy_nami_expected.html index 34fccdd..2450c02 100644 --- a/tests/files/text/asnyk_miedzy_nami_expected.html +++ b/tests/files/text/asnyk_miedzy_nami_expected.html @@ -1,47 +1,43 @@
    -
    -

    Spis treści

    -
      -
      1. Miłość platoniczna: 1
      2. Natura: 1
      3. Nicość: 1

      -Adam AsnykMiłość platonicznaMiędzy nami nic nie było +Adam AsnykMiłość platonicznaMiędzy nami nic nie było

      -
      - 1
      Między nami Nicośćnic nie było! +
      +1
      Między nami Nicośćnic nie było!
      -
      Żadnych zwierzeń, wyznań żadnych!
      -
      Nic nas z sobą nie łączyło —
      -
      Prócz wiosennych marzeń zdradnych;
      +
      Żadnych zwierzeń, wyznań żadnych!
      +
      Nic nas z sobą nie łączyło —
      +
      Prócz wiosennych marzeń zdradnych;
      -
      - 5
      +
      +5
      NaturaPrócz tych woni, barw i blasków,
      -
      Unoszących się w przestrzeni;
      -
      Prócz szumiących śpiewem lasków
      -
      I tej świeżej łąk zieleni;
      +
      Unoszących się w przestrzeni;
      +
      Prócz szumiących śpiewem lasków
      +
      I tej świeżej łąk zieleni;
      -
      -
      Prócz tych kaskad i potoków,
      - 10
      Zraszających każdy parów,
      -
      Prócz girlandy tęcz, obłoków,
      -
      Prócz natury słodkich czarów;
      +
      +
      Prócz tych kaskad i potoków,
      +10
      Zraszających każdy parów,
      +
      Prócz girlandy tęcz, obłoków,
      +
      Prócz natury słodkich czarów;
      -
      -
      Prócz tych wspólnych, jasnych zdrojów,
      -
      Z których serce zachwyt piło;
      - 15
      Prócz pierwiosnków[1] i powojów,—
      -
      Między nami nic nie było! +
      +
      Prócz tych wspólnych, jasnych zdrojów,
      +
      Z których serce zachwyt piło;
      +15
      Prócz pierwiosnków[1] i powojów,—
      +
      Między nami nic nie było!

      Przypisy

      -[1]

      pierwiosnek — taki kwiatek [przypis edytorski]

      +[1]

      pierwiosnek — taki kwiatek [przypis edytorski]

      diff --git a/tests/files/text/asnyk_miedzy_nami_expected.legacy.html b/tests/files/text/asnyk_miedzy_nami_expected.legacy.html deleted file mode 100644 index 7004f5a..0000000 --- a/tests/files/text/asnyk_miedzy_nami_expected.legacy.html +++ /dev/null @@ -1,47 +0,0 @@ -
      -
      -

      Spis treści

      -
        -
        -
          -
        1. Miłość platoniczna: 1 2
        2. -
        3. Natura: 1
        4. -
        5. Nicość: 1
        6. -
        -

        -Adam AsnykMiłość platonicznaMiędzy nami nic nie było -

        -Miłość platoniczna
        - 1
        Między nami Nicośćnic nie było! -
        -
        Żadnych zwierzeń, wyznań żadnych!
        -
        Nic nas z sobą nie łączyło —
        -
        Prócz wiosennych marzeń zdradnych;
        -
        -
        - 5
        -NaturaPrócz tych woni, barw i blasków,
        -
        Unoszących się w przestrzeni;
        -
        Prócz szumiących śpiewem lasków
        -
        I tej świeżej łąk zieleni;
        -
        -
        -
        Prócz tych kaskad i potoków,
        - 10
        Zraszających każdy parów,
        -
        Prócz girlandy tęcz, obłoków,
        -
        Prócz natury słodkich czarów;
        -
        -
        -
        Prócz tych wspólnych, jasnych zdrojów,
        -
        Z których serce zachwyt piło;
        - 15
        Prócz pierwiosnków[1] i powojów,—
        -
        Między nami nic nie było! -
        -
        -
        -

        Przypisy

        -
        -[1]

        pierwiosnek — taki kwiatek [przypis edytorski]

        -
        -
        -
        diff --git a/tests/files/text/asnyk_miedzy_nami_fragments.html b/tests/files/text/asnyk_miedzy_nami_fragments.html index eeeaee6..9fd6a25 100644 --- a/tests/files/text/asnyk_miedzy_nami_fragments.html +++ b/tests/files/text/asnyk_miedzy_nami_fragments.html @@ -1,54 +1,54 @@ 1: Nicość -
        nic nie było!
        +
        nic nie było!
        1189062500041: Miłość platoniczna -

        Między nami nic nie było +

        Między nami nic nie było

        -
        Między nami nic nie było! +
        Między nami nic nie było!
        -
        Żadnych zwierzeń, wyznań żadnych!
        -
        Nic nas z sobą nie łączyło —
        -
        Prócz wiosennych marzeń zdradnych;
        +
        Żadnych zwierzeń, wyznań żadnych!
        +
        Nic nas z sobą nie łączyło —
        +
        Prócz wiosennych marzeń zdradnych;
        -
        -Prócz tych woni, barw i blasków,
        -
        Unoszących się w przestrzeni;
        -
        Prócz szumiących śpiewem lasków
        -
        I tej świeżej łąk zieleni;
        +
        +Prócz tych woni, barw i blasków,
        +
        Unoszących się w przestrzeni;
        +
        Prócz szumiących śpiewem lasków
        +
        I tej świeżej łąk zieleni;
        -
        Prócz tych kaskad i potoków,
        -
        Zraszających każdy parów,
        -
        Prócz girlandy tęcz, obłoków,
        -
        Prócz natury słodkich czarów;
        +
        Prócz tych kaskad i potoków,
        +
        Zraszających każdy parów,
        +
        Prócz girlandy tęcz, obłoków,
        +
        Prócz natury słodkich czarów;
        -
        Prócz tych wspólnych, jasnych zdrojów,
        -
        Z których serce zachwyt piło;
        -
        Prócz pierwiosnków i powojów,—
        -
        Między nami nic nie było!
        +
        Prócz tych wspólnych, jasnych zdrojów,
        +
        Z których serce zachwyt piło;
        +
        Prócz pierwiosnków i powojów,—
        +
        Między nami nic nie było!
        1189062528872: Natura -
        Prócz tych woni, barw i blasków,
        -
        Unoszących się w przestrzeni;
        -
        Prócz szumiących śpiewem lasków
        -
        I tej świeżej łąk zieleni;
        +
        Prócz tych woni, barw i blasków,
        +
        Unoszących się w przestrzeni;
        +
        Prócz szumiących śpiewem lasków
        +
        I tej świeżej łąk zieleni;
        -
        Prócz tych kaskad i potoków,
        -
        Zraszających każdy parów,
        -
        Prócz girlandy tęcz, obłoków,
        -
        Prócz natury słodkich czarów;
        +
        Prócz tych kaskad i potoków,
        +
        Zraszających każdy parów,
        +
        Prócz girlandy tęcz, obłoków,
        +
        Prócz natury słodkich czarów;
        -
        Prócz tych wspólnych, jasnych zdrojów,
        -
        Z których serce zachwyt piło;
        -
        Prócz pierwiosnków i powojów,—
        -
        Między nami nic nie było!
        +
        Prócz tych wspólnych, jasnych zdrojów,
        +
        Z których serce zachwyt piło;
        +
        Prócz pierwiosnków i powojów,—
        +
        Między nami nic nie było!
        diff --git a/tests/files/text/asnyk_miedzy_nami_refs.html b/tests/files/text/asnyk_miedzy_nami_refs.html index 703d79c..8bd2327 100644 --- a/tests/files/text/asnyk_miedzy_nami_refs.html +++ b/tests/files/text/asnyk_miedzy_nami_refs.html @@ -1,6 +1,6 @@ -sec7 -
        -
        Prócz tych wspólnych, jasnych zdrojów,
        -
        Z których serce zachwyt piło;
        -
        Prócz pierwiosnków
        +f15 +
        +
        Prócz tych wspólnych, jasnych zdrojów,
        +
        Z których serce zachwyt piło;
        +
        Prócz pierwiosnków
        diff --git a/tests/test_html.py b/tests/test_html.py index 1d698fd..5e5ee30 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1,29 +1,16 @@ # This file is part of Librarian, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # -import re +import io from unittest import TestCase -from librarian import NoDublinCore from librarian.builders import builders from librarian.document import WLDocument -from librarian.parser import WLDocument as LegacyWLDocument from .utils import get_fixture class TransformTest(TestCase): maxDiff = None - def test_transform_legacy(self): - expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.legacy.html') - - html = LegacyWLDocument.from_file( - get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml') - ).as_html().get_bytes().decode('utf-8') - - html = re.sub(r'idm\d+', 'idmNNN', html) - with open(expected_output_file_path) as f: - self.assertEqual(f.read(), html) - def test_transform(self): expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html') html = WLDocument( @@ -33,23 +20,9 @@ class TransformTest(TestCase): with open(expected_output_file_path) as f: self.assertEqual(html, f.read()) - def test_no_dublincore(self): - with self.assertRaises(NoDublinCore): - LegacyWLDocument.from_file( - get_fixture('text', 'asnyk_miedzy_nami_nodc.xml') - ).as_html() - - def test_passing_parse_dublincore_to_transform(self): - """Passing parse_dublincore=False to transform omits DublinCore parsing.""" - LegacyWLDocument.from_file( - get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'), - parse_dublincore=False, - ).as_html() - def test_empty(self): self.assertIsNone( - LegacyWLDocument.from_bytes( - b'', - parse_dublincore=False, - ).as_html() + WLDocument( + filename=io.BytesIO(b''), + ).build(builders['html'], base_url='/') ) diff --git a/tests/test_html_annotations.py b/tests/test_html_annotations.py index bdbe4fb..ccf8030 100644 --- a/tests/test_html_annotations.py +++ b/tests/test_html_annotations.py @@ -1,12 +1,16 @@ # This file is part of Librarian, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # +import io import unittest -from librarian.parser import WLDocument +from librarian.builders import HtmlBuilder +from librarian.document import WLDocument from librarian.html import extract_annotations class AnnotationsTests(unittest.TestCase): + maxDiff = None + def _test_annotation(self, expected, got, name): self.assertTrue( got[0].startswith('anchor-'), @@ -108,19 +112,19 @@ class AnnotationsTests(unittest.TestCase): 'częściej: gemajn, szeregowiec w wojsku polskim cudzoziemskiego autoramentu.', ( 'pe', ['daw.', 'niem.'], - 'gemajna (daw., z niem. gemein: zwykły) \u2014 częściej: gemajn, ' - 'szeregowiec w wojsku polskim cudzoziemskiego autoramentu. [przypis edytorski]', - '

        gemajna (daw., z niem. gemein: zwykły) ' - '\u2014 częściej: gemajn, szeregowiec w wojsku polskim cudzoziemskiego autoramentu. [przypis edytorski]

        ' + 'gemajna (daw., z\u00A0niem. gemein: zwykły) \u2014 częściej: gemajn, ' + 'szeregowiec w\u00A0wojsku polskim cudzoziemskiego autoramentu. [przypis edytorski]', + '

        gemajna (daw., z\u00A0niem. gemein: zwykły) ' + '\u2014 częściej: gemajn, szeregowiec w\u00A0wojsku polskim cudzoziemskiego autoramentu. [przypis edytorski]

        ' ), 'Footnote with multiple and qualifiers and emphasis.'), ) xml_src = ''' %s ''' % "".join( t[0] for t in annotations) - html = WLDocument.from_bytes( - xml_src.encode('utf-8'), - parse_dublincore=False).as_html().get_file() + html = WLDocument( + filename=io.BytesIO(xml_src.encode('utf-8')) + ).build(HtmlBuilder, base_url='/').get_file() res_annotations = list(extract_annotations(html)) for i, (src, expected, name) in enumerate(annotations): diff --git a/tests/test_html_examples.py b/tests/test_html_examples.py new file mode 100644 index 0000000..582123c --- /dev/null +++ b/tests/test_html_examples.py @@ -0,0 +1,49 @@ +import io +import os +from unittest import TestCase +from librarian.builders import HtmlBuilder +from librarian.document import WLDocument +from librarian.elements import WL_ELEMENTS +from .utils import get_fixture, get_all_fixtures + + +class HtmlExamplesTests(TestCase): + maxDiff = None + + @classmethod + def setUpClass(cls): + with open(get_fixture('tags', 'base.xml'), 'rb') as f: + cls.base_xml = f.read() + + def test_examples(self): + for tag in WL_ELEMENTS: + with self.subTest(tag): + self.tag_test(tag) + for path in get_all_fixtures('tags'): + if os.path.isdir(path): + name = path.rsplit('/', 1)[1] + self.assertIn(name, WL_ELEMENTS) + + def tag_test(self, tag): + for fixture in get_all_fixtures(f'tags/{tag}', '*.xml'): + with self.subTest(tag=tag, n=fixture.rsplit('/', 1)[-1].rsplit('.', 1)[0]): + with open(fixture, 'rb') as f: + xml_input = f.read() + xml_file = io.BytesIO(self.base_xml.replace(b'', xml_input)) + doc = WLDocument(filename=xml_file) + html = HtmlBuilder(base_url='/').build(doc).get_bytes().decode('utf-8') + + with open(fixture.rsplit('.', 1)[0] + '.expected.html', 'r') as f: + expected_html = f.read() + try: + with open(fixture.rsplit('.', 1)[0] + '.expected.toc.html', 'r') as f: + expected_toc = f.read() + except: + expected_toc = '' + try: + with open(fixture.rsplit('.', 1)[0] + '.expected.themes.html', 'r') as f: + expected_themes = f.read() + except: + expected_themes = '' + + self.assertEqual(html, expected_html) diff --git a/tests/test_html_fragments.py b/tests/test_html_fragments.py index 2d55362..a89e94f 100644 --- a/tests/test_html_fragments.py +++ b/tests/test_html_fragments.py @@ -13,7 +13,7 @@ class FragmentsTest(unittest.TestCase): expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_fragments.html') closed_fragments, open_fragments = extract_fragments( - get_fixture('text', 'asnyk_miedzy_nami_expected.legacy.html')) + get_fixture('text', 'asnyk_miedzy_nami_expected.html')) assert not open_fragments fragments_text = "\n\n".join("%s: %s\n%s" % (f.id, f.themes, f) for f in sorted(closed_fragments.values(), key=lambda f: f.id)) with open(expected_output_file_path, 'rb') as f: diff --git a/tests/test_html_transform_abstrakt.py b/tests/test_html_transform_abstrakt.py index 4f36b80..ae7fbe5 100644 --- a/tests/test_html_transform_abstrakt.py +++ b/tests/test_html_transform_abstrakt.py @@ -2,16 +2,19 @@ # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # import unittest -from librarian.parser import WLDocument -from librarian.html import transform_abstrakt +from librarian.document import WLDocument +from librarian.builders.html import AbstraktHtmlBuilder from .utils import get_fixture class AbstractTests(unittest.TestCase): def test_abstrakt(self): - transform_abstrakt( - WLDocument.from_file( - get_fixture('text', 'abstrakt.xml'), - parse_dublincore=False - ).edoc.getroot().find('.//abstrakt') - ) + builder = AbstraktHtmlBuilder() + got = builder.build( + WLDocument( + filename=get_fixture('text', 'abstrakt.xml'), + ) + ).get_bytes().decode('utf-8') + with open(get_fixture('text', 'abstrakt.expected.html')) as f: + expected = f.read() + self.assertEqual(expected, got) diff --git a/tests/test_picture.py b/tests/test_picture.py deleted file mode 100644 index afa4da8..0000000 --- a/tests/test_picture.py +++ /dev/null @@ -1,56 +0,0 @@ -# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. -# -from os import path -import unittest -from librarian import picture, dcparser -from tests.utils import get_all_fixtures, get_fixture - - -class PictureTests(unittest.TestCase): - def test_wlpictureuri(self): - uri = picture.WLPictureURI('http://wolnelektury.pl/katalog/obraz/angelus-novus') - - def check_load(self, xml_file): - pi = dcparser.parse(xml_file, picture.PictureInfo) - self.assertIsNotNone(pi) - self.assertIsInstance(pi, picture.PictureInfo) - - def test_load(self): - for fixture in get_all_fixtures('picture', '*.xml'): - with self.subTest(fixture=fixture): - self.check_load(fixture) - - def test_wlpicture(self): - with open(get_fixture('picture', 'angelus-novus.xml')) as f: - wlp = picture.WLPicture.from_file(f) - pi = wlp.picture_info - - self.assertEqual(pi.type[0], "Image") - self.assertEqual(pi.mime_type, 'image/jpeg') - self.assertEqual(wlp.mime_type, 'image/jpeg') - self.assertEqual(wlp.slug, 'angelus-novus') - self.assertTrue(path.exists(wlp.image_path)) - - f = wlp.image_file() - f.close() - - - def test_picture_parts(self): - with open(get_fixture('picture', 'angelus-novus.xml')) as f: - wlp = picture.WLPicture.from_file(f) - parts = list(wlp.partiter()) - expect_parts = 4 - self.assertEqual(len(parts), expect_parts, "there should be %d parts of the picture" % expect_parts) - motifs = set() - names = set() - - for p in parts: - for m in p['themes']: - motifs.add(m) - for p in parts: - if p['object']: - names.add(p['object']) - - self.assertEqual(motifs, {'anioł historii', 'spojrzenie'}, "missing motifs, got: %s" % motifs) - self.assertEqual(names, {'obraz cały', 'skrzydło'}, 'missing objects, got: %s' % names) diff --git a/tests/test_ref.py b/tests/test_ref.py index 2383866..d75228e 100644 --- a/tests/test_ref.py +++ b/tests/test_ref.py @@ -11,12 +11,14 @@ from lxml import etree class RefTests(TestCase): def test_snippet(self): doc = WLDocument(filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')) - doc._compat_assign_section_ids() + + hb = builders['html']() + hb.assign_ids(doc.tree) refs = [] for ref in doc.references(): snippet = ref.get_snippet() - b = builders['html']() + b = builders['html-snippet']() for s in snippet: s.html_build(b) diff --git a/tox.ini b/tox.ini index ecf3ecc..5797049 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,17 @@ [tox] envlist = clean, - py{37,38,39,310,311}, + py{38,39,310,311}, stats [testenv] deps = coverage -passenv = HOME ; Needed to find locally installed fonts when testing PDF production. +passenv = HOME # Needed to find locally installed fonts when testing PDF production. download = true commands = coverage run -install_command = pip install numpy; pip install --extra-index-url https://py.mdrn.pl/simple {packages} +install_command = pip install --extra-index-url https://py.mdrn.pl/simple {packages} [testenv:clean] basepython = python3