"librarian=librarian.command_line:main"
]
},
- scripts=['scripts/book2html',
+ scripts=[
'scripts/book2txt',
'scripts/book2pdf',
'scripts/book2fb2',
self.current_margin = 0
self.starting_block = True
- def push_legacy_margin(self, margin):
- if margin:
- if self.pieces:
- self.pieces[-1] = self.pieces[-1].rstrip(' ')
- self.pieces.append('\r\n' * margin)
- self.current_margin += margin
- self.starting_block = True
-
def push_margin(self, margin):
if margin:
if self.pieces:
"""
file_extension = "txt"
identifier = "txt"
+ after_child_fn = 'txt_after_child'
+ debug = False
orphans = False
+ normalize_whitespace = True
default_license_description = {
"pol": (
def push_margin(self, margin):
self.current_fragments[-1].push_margin(margin)
- def push_legacy_margin(self, margin, where=None):
- self.current_fragments[-1].push_legacy_margin(margin)
-
def build(self, document, raw_text=False, **kwargs):
document.tree.getroot().txt_build(self)
meta = document.meta
for translator in meta.translators
)
)
- #builder.push_margin(2)
- self.push_legacy_margin(1)
+ builder.push_margin(2)
if meta.isbn_txt:
- #builder.push_margin(2)
- self.push_legacy_margin(1)
+ self.push_margin(2)
isbn = meta.isbn_txt
if isbn.startswith(('ISBN-' , 'ISBN ')):
isbn = isbn[5:]
self.push_text('ISBN {isbn}'.format(isbn=isbn))
#builder.push_margin(5)
- #builder.push_margin(4)
- self.push_legacy_margin(1)
+ self.push_margin(4)
self.exit_fragment()
- text = ''.join(self.fragments['header'].pieces) + ''.join(self.fragments[None].pieces)
+ text = ''.join(self.fragments[None].pieces).lstrip()
if raw_text:
result = text
else:
+ text = ''.join(self.fragments['header'].pieces) + text
+
if meta.license:
license_description = self.license_description['pol'].format(meta=meta)
else:
"wywiad_odp": blocks.WywiadOdp,
# Inline MathML, should really be namespaced.
- "mrow": etree.ElementBase,
- "mi": etree.ElementBase,
- "mo": etree.ElementBase,
- "msup": etree.ElementBase,
- "mn": etree.ElementBase,
- "mfrac": etree.ElementBase,
- "mfenced": etree.ElementBase,
+ "mrow": styles.MRow,
+ "mi": styles.M,
+ "mo": styles.M,
+ "msup": styles.MSup,
+ "mn": styles.M,
+ "mfrac": styles.MFrac,
+ "mfenced": styles.MFenced,
}
text_substitutions = [
('---', '—'),
('--', '–'),
- #('...', '…'), # Temporary turnoff for epub
+ ('...', '…'),
(',,', '„'),
('"', '”'),
('\ufeff', ''),
-
- ("'", "\u2019"), # This was enabled for epub.
+ ("'", "\u2019"),
]
@property
text = text or ''
for e, s in self.text_substitutions:
text = text.replace(e, s)
- # FIXME: TEmporary turnoff
-# text = re.sub(r'\s+', ' ', text)
-### TODO: Added now for epub
+
+ if getattr(builder, 'normalize_whitespace', False):
+ text = re.sub(r'\s+', ' ', text)
if getattr(builder, 'hyphenator', None) is not None:
newt = ''
text = text.rstrip()
builder.push_text(text)
for i, child in enumerate(self):
+ real_child_count = 0
if isinstance(child, WLElement):
getattr(child, build_method)(builder)
+ self.after_child(builder, real_child_count)
+ real_child_count += 1
+
# FIXME base builder api
elif getattr(builder, 'debug', False) and child.tag is etree.Comment:
builder.process_comment(child)
text = text.rstrip()
builder.push_text(text)
+ def after_child(self, builder, child_count):
+ fn = getattr(builder, 'after_child_fn', None)
+ if fn:
+ getattr(self, builder.after_child_fn)(builder, child_count)
+
+ def txt_after_child(self, builder, child_count):
+ pass
+
def _txt_build_inner(self, builder):
self._build_inner(builder, 'txt_build')
def txt_build(self, builder):
- if hasattr(self, 'TXT_LEGACY_TOP_MARGIN'):
- builder.push_legacy_margin(self.TXT_LEGACY_TOP_MARGIN)
- else:
- builder.push_margin(self.TXT_TOP_MARGIN)
+ builder.push_margin(self.TXT_TOP_MARGIN)
builder.push_text(self.TXT_PREFIX, True)
self._txt_build_inner(builder)
builder.push_text(self.TXT_SUFFIX, True)
- if hasattr(self, 'TXT_LEGACY_BOTTOM_MARGIN'):
- builder.push_legacy_margin(self.TXT_LEGACY_BOTTOM_MARGIN)
- else:
- builder.push_margin(self.TXT_BOTTOM_MARGIN)
+ builder.push_margin(self.TXT_BOTTOM_MARGIN)
def _html_build_inner(self, builder):
self._build_inner(builder, 'html_build')
class Dedykacja(WLElement):
NUMBERING = 'i'
- TXT_LEGACY_TOP_MARGIN = 2
+ TXT_TOP_MARGIN = 2
+ TXT_BOTTOM_MARGIN = 4
EPUB_TAG = HTML_TAG = "div"
EPUB_CLASS = HTML_CLASS = "dedication"
CAN_HAVE_TEXT = False
TXT_TOP_MARGIN = 3
- TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 0
+ TXT_BOTTOM_MARGIN = 3
HTML_TAG = 'blockquote'
TXT_TOP_MARGIN = 3
TXT_BOTTOM_MARGIN = 3
- TXT_LEGACY_TOP_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 0
HTML_TAG = 'blockquote'
TXT_TOP_PARGIN = 2
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 2
- TXT_LEGACY_BOTTOM_MARGIN = 0
TXT_PREFIX = "/ "
TXT_SUFFIX = " /"
TXT_TOP_MARGIN = 3
TXT_BOTTOM_MARGIN = 3
- TXT_LEGACY_TOP_MARGIN = 3
- TXT_LEGACY_BOTTOM_MARGIN = 1
HTML_TAG = "div"
HTML_CLASS = "person-list"
TXT_TOP_MARGIN = 1
TXT_BOTTOM_MARGIN = 1
- TXT_LEGACY_TOP_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 0
TXT_PREFIX = " * "
EPUB_TAG = HTML_TAG = "li"
TXT_TOP_MARGIN = 3
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 3
- TXT_LEGACY_BOTTOM_MARGIN = 0
HTML_TAG = "h4"
class Kol(WLElement):
EPUB_TAG = HTML_TAG = 'td'
+ TXT_PREFIX = ' ' * 4
class Tabela(WLElement):
NUMBERING = 'i'
+ CAN_HAVE_TEXT = False
+
+ TXT_TOP_MARGIN = 3
+ TXT_BOTTOM_MARGIN = 3
EPUB_TAG = HTML_TAG = 'table'
class Wiersz(WLElement):
+ CAN_HAVE_TEXT = False
EPUB_TAG = HTML_TAG = 'tr'
+ TXT_TOP_MARGIN = 1
+ TXT_BOTTOM_MARGIN = 1
class AutorUtworu(HeaderElement):
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_BOTTOM_MARGIN = 2
HTML_CLASS = 'wl author'
class DzieloNadrzedne(HeaderElement):
TXT_BOTTOM_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 1
HTML_CLASS = "wl collection"
class Motto(WLElement):
NUMBERING = 'i'
- TXT_LEGACY_TOP_MARGIN = 4
- TXT_LEGACY_BOTTOM_MARGIN = 2
+ TXT_TOP_MARGIN = 4
+ TXT_BOTTOM_MARGIN = 2
EPUB_TAG = HTML_TAG = "div"
EPUB_CLASS = HTML_CLASS = "motto"
class NazwaUtworu(HeaderElement):
TXT_BOTTOM_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 1
HTML_CLASS = 'wl title'
class Podtytul(HeaderElement):
TXT_BOTTOM_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 1
HTML_CLASS = 'wl subtitle'
TXT_TOP_MARGIN = 5
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 5
- TXT_LEGACY_BOTTOM_MARGIN = 0
EPUB_TAG = HTML_TAG = "h2"
HTML_CLASS = "wl"
TXT_TOP_MARGIN = 3
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 3
- TXT_LEGACY_BOTTOM_MARGIN = 0
HTML_TAG = "h4"
TXT_TOP_MARGIN = 4
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 4
- TXT_LEGACY_BOTTOM_MARGIN = 0
HTML_TAG = 'h3'
HTML_CLASS = 'wl'
TXT_TOP_MARGIN = 4
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 4
- TXT_LEGACY_BOTTOM_MARGIN = 0
HTML_TAG = 'h3'
class Master(WLElement):
CAN_HAVE_TEXT = False
- TXT_LEGACY_BOTTOM_MARGIN = 2
+ TXT_BOTTOM_MARGIN = 2
TXT_TOP_MARGIN = 2
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 2
- TXT_LEGACY_BOTTOM_MARGIN = 0
EPUB_CLASS = 'paragraph'
TXT_TOP_MARGIN = 2
TXT_BOTTOM_MARGIN = 2
- TXT_LEGACY_TOP_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 0
EPUB_TAG = HTML_TAG = 'div'
EPUB_CLASS = HTML_CLASS = 'stanza'
TXT_TOP_MARGIN = 1
TXT_BOTTOM_MARGIN = 1
- TXT_LEGACY_TOP_MARGIN = 1
- TXT_LEGACY_BOTTOM_MARGIN = 0
EPUB_TAG = HTML_TAG = 'div'
EPUB_CLASS = 'verse'
class SekcjaAsterysk(WLElement):
TXT_TOP_MARGIN = 2
TXT_BOTTOM_MARGIN = 4
- TXT_LEGACY_TOP_MARGIN = 2
- TXT_LEGACY_BOTTOM_MARGIN = 2
EPUB_TAG = HTML_TAG = "p"
HTML_CLASS = HTML_CLASS = "spacer-asterisk"
class SekcjaSwiatlo(WLElement):
TXT_BOTTOM_MARGIN = 6
- TXT_LEGACY_BOTTOM_MARGIN = 4
HTML_TAG = "hr"
HTML_CLASS = "spacer"
class SeparatorLinia(WLElement):
TXT_TOP_MARGIN = 4
TXT_BOTTOM_MARGIN = 4
- TXT_LEGACY_TOP_MARGIN = 2
- TXT_LEGACY_BOTTOM_MARGIN = 2
EPUB_TAG = HTML_TAG = "hr"
EPUB_CLASS = HTML_CLASS = "spacer-line"
# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
#
from .indeks_dolny import IndeksDolny
-from .mat import Mat
+from .mat import Mat, M, MRow, MFenced, MFrac, MSup
from .slowo_obce import SlowoObce
from .tytul_dziela import TytulDziela
from .wieksze_odstepy import WiekszeOdstepy
class Mat(WLElement):
+ STRIP = True
+
def html_build(self, builder):
e = copy(self)
e.tag = 'math'
def epub_build(self, builder):
builder.start_element('img', {"src": builder.mathml(self)})
builder.end_element()
+
+
+class M(WLElement):
+ STRIP = True
+
+
+class MRow(M):
+ pass
+
+
+class MFenced(M):
+ TXT_PREFIX = '('
+ TXT_SUFFIX = ')'
+
+
+class MFrac(M):
+ TXT_PREFIX = '('
+ TXT_SUFFIX = ')'
+
+ def txt_after_child(self, builder, child_count):
+ if child_count:
+ builder.push_text(') / (')
+
+
+class MSup(M):
+ def txt_after_child(self, builder, child_count):
+ if child_count:
+ builder.push_text(' ^ ')
}
get_epub_attr = get_html_attr
+
+ def txt_build(self, builder):
+ szer = self.get('szer', '1').strip()
+ if szer.endswith('em'):
+ szer = szer[:-2]
+ try:
+ szer = int(szer)
+ except:
+ szer = 1
+ builder.push_text(' ' * 4 * szer)
</div>
<div class="didaskalia" id="i4">uderzając w stół</div>
<div class="stanza" id="i5">
-<div class="wl verse" id="f3">By kto... niech go piorun trzaśnie!</div>
+<div class="wl verse" id="f3">By kto… niech go piorun trzaśnie!</div>
<div class="wl verse" id="f4">Długo będzie na to czekał,</div>
</div>
<div class="didaskalia" id="i6">po krótkim milczeniu, biorąc talerz</div>
<div class="stanza" id="i9">
<div class="wl verse" id="f8">Bawi z nami — w domu Klary,</div>
<div class="wl verse" id="f9">Bo krewniaczka jej daleka,</div>
-<a href="#f10" class="wl-num">10</a><div class="wl verse" id="f10">Ale mnie się wszystko zdaje...</div>
+<a href="#f10" class="wl-num">10</a><div class="wl verse" id="f10">Ale mnie się wszystko zdaje…</div>
</div>
</div>
</div>
<a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1">Więc jako dawniej czynili mocarze,</div>
<div class="wl verse" id="f2">Z Lechem się mieniał Scyta na obrączki;</div>
<div class="wl verse" id="f3">A pokochawszy mocniej sercem, w darze</div>
-<div class="wl verse" id="f4">Dał mu koronę... stąd nasza korona.</div>
+<div class="wl verse" id="f4">Dał mu koronę… stąd nasza korona.</div>
<a href="#f5" class="wl-num">5</a><div class="wl verse" id="f5">Zbawiciel niegdyś wyciągając rączki</div>
<div class="wl verse" id="f6">Szedł do niej z matki zadumanej łona</div>
<div class="wl verse" id="f7">I ku rubinom podawał się cały</div>
<div id="book-text">
<h4 id="i1">GŁOS HESI</h4>
<div class="kwestia">
-<a href="#f1" class="wl-num">1</a><p class="wl paragraph" id="f1">Mamuńciu, tak zimno! troszkę ciepłej wody...</p>
+<a href="#f1" class="wl-num">1</a><p class="wl paragraph" id="f1">Mamuńciu, tak zimno! troszkę ciepłej wody…</p>
</div>
<h4 id="i2">DULSKA</h4>
<div class="kwestia">
-<a href="#f2" class="wl-num">2</a><p class="wl paragraph" id="f2">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.
+<a href="#f2" class="wl-num">2</a><p class="wl paragraph" id="f2">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ę.</p>
</div>
</div>
<div class="motto" id="i6">
<div class="stanza" id="i5">
<a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1"><em class="foreign-word">Dovete adunque sapere come sono/
-due generazioni da combattere...../
+due generazioni da combattere…../
bisogna essere volpe e leone.</em></div>
</div>
</div>
<a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1">Piękne dobra w każdym względzie —</div>
<div class="wl verse" id="f2">Lasy — gleba wyśmienita —</div>
<div class="wl verse" id="f3">Dobrą żoną pewnie będzie —</div>
-<div class="wl verse" id="f4">Co za czynsze! — To kobiéta!...</div>
+<div class="wl verse" id="f4">Co za czynsze! — To kobiéta!…</div>
<a href="#f5" class="wl-num">5</a><div class="wl verse" id="f5">Trzy folwarki!</div>
</div>
</div>
<div class="wl verse" id="f3">I nie przyjmował nigdy, jak wiek wiekiem.</div>
<div class="wl verse" id="f4">Bo glina w glinę wtapia się bez przerwy,</div>
<a href="#f5" class="wl-num">5</a><div class="wl verse" id="f5">Gdy sprzeczne ciała zbija się aż ćwiekiem</div>
-<div class="wl verse" id="f6">Później... lub pierwéj...</div>
+<div class="wl verse" id="f6">Później… lub pierwéj…</div>
</div>
<div class="note"><p class="wl paragraph" id="i2">Pisałem w Paryżu 1856 w styczniu.</p></div>
</div>
<div id="book-text">
<a href="#f1" class="wl-num">1</a><p class="wl paragraph" id="f1">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.</p>
+gdy skończono oporządzać jego mieszkanie. […] Rzecz dziwna, czym jest mundur dla takich ludzi.</p>
<div class="note"><p class="wl paragraph" id="i1"><em class="author-emphasis">Uwaga tłumacza</em>. Drukowane obecnie w „Nowej Reformie”
<em class="book-title">Wspomnienia Sybiraka</em> (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. [...]</p></div>
+oznaczając te nazwiska tylko pierwszymi literami, z dodaniem czasami końcówek. […]</p></div>
</div>
<div id="book-text"><blockquote><div class="stanza" id="i1">
<a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1">Tymczasem przenoś duszę moją utęsknioną</div>
-<div class="wl verse" id="f2">Do tych pagórków leśnych, do tych łąk zielonych...</div>
+<div class="wl verse" id="f2">Do tych pagórków leśnych, do tych łąk zielonych…</div>
</div></blockquote></div>
<div id="book-text">
-<a href="#f1" class="wl-num">1</a><p class="wl paragraph" id="f1">Na czwarty dzień przywiózł mu stójka z osłowickiej apteki <em class="foreign-word">diachylum</em>; Zołzikiewicz rozsmarował na płatek...</p>
+<a href="#f1" class="wl-num">1</a><p class="wl paragraph" id="f1">Na czwarty dzień przywiózł mu stójka z osłowickiej apteki <em class="foreign-word">diachylum</em>; Zołzikiewicz rozsmarował na płatek…</p>
</div>
<div id="book-text">
<table>
- <tr>
- <td>a</td>
- <td>b</td>
- </tr>
- <tr>
- <td>c</td>
- <td>d</td>
- </tr>
+<tr>
+<td>a</td>
+<td>b</td>
+</tr>
+<tr>
+<td>c</td>
+<td>d</td>
+</tr>
</table>
<table class="border">
- <tr>
- <td>a</td>
- <td>b</td>
- </tr>
- <tr>
- <td>c</td>
- <td>d</td>
- </tr>
+<tr>
+<td>a</td>
+<td>b</td>
+</tr>
+<tr>
+<td>c</td>
+<td>d</td>
+</tr>
</table>
</div>
Kilka uwag o <em class="book-title">„Hamlecie”</em>
Szekspira
</em>
- pióra...</p>
+ pióra…</p>
</div>
<div id="book-text">
<h1>
-<span class="wl author" id="i1">Julisz Słowacki</span><span class="wl title" id="i2">Anioł ognisty — mój anioł lewy...</span>
+<span class="wl author" id="i1">Julisz Słowacki</span><span class="wl title" id="i2">Anioł ognisty — mój anioł lewy…</span>
</h1>
<div class="stanza" id="i3">
<a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1">Anioł ognisty — mój anioł lewy</div>
-<div id="book-text"><div class="stanza" id="i1"><div class="wl verse" id="f9"><a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1">zwykły</div>
- <div class="wl verse verse-indent verse-indent-1" id="f2">wcięty</div>
- <div class="wl verse verse-indent verse-indent-1" id="f3">wcięty 1</div>
- <div class="wl verse verse-indent verse-indent-2" id="f4">wcięty 2</div>
- <a href="#f5" class="wl-num">5</a><div class="wl verse verse-indent verse-indent-25" id="f5">wcięty 25</div>
- <div class="wl verse verse-p" id="f6">akapitowy</div>
- <div class="wl verse verse-center" id="f7">środek</div>
- <div class="wl verse verse-right" id="f8">do prawej</div></div></div></div>
+<div id="book-text"><div class="stanza" id="i1">
+<a href="#f1" class="wl-num">1</a><div class="wl verse" id="f1">zwykły</div>
+<div class="wl verse verse-indent verse-indent-1" id="f2">wcięty</div>
+<div class="wl verse verse-indent verse-indent-1" id="f3">wcięty 1</div>
+<div class="wl verse verse-indent verse-indent-2" id="f4">wcięty 2</div>
+<a href="#f5" class="wl-num">5</a><div class="wl verse verse-indent verse-indent-25" id="f5">wcięty 25</div>
+<div class="wl verse verse-p" id="f6">akapitowy</div>
+<div class="wl verse verse-center" id="f7">środek</div>
+<div class="wl verse verse-right" id="f8">do prawej</div>
+</div></div>
<strofa>
- <wers>zwykły</wers>
- <wers_wciety>wcięty</wers_wciety>
- <wers_wciety typ="1">wcięty 1</wers_wciety>
- <wers_wciety typ="2">wcięty 2</wers_wciety>
- <wers_wciety typ="25">wcięty 25</wers_wciety>
- <wers_akap>akapitowy</wers_akap>
- <wers_srodek>środek</wers_srodek>
+ <wers>zwykły</wers>/
+ <wers_wciety>wcięty</wers_wciety>/
+ <wers_wciety typ="1">wcięty 1</wers_wciety>/
+ <wers_wciety typ="2">wcięty 2</wers_wciety>/
+ <wers_wciety typ="25">wcięty 25</wers_wciety>/
+ <wers_akap>akapitowy</wers_akap>/
+ <wers_srodek>środek</wers_srodek>/
<wers_do_prawej>do prawej</wers_do_prawej>
</strofa>
<div class="wl verse" id="f4">Blade jak świt,</div>
<a href="#f5" class="wl-num">5</a><div class="wl verse" id="f5">— Gdy życia koniec szepce do początku:</div>
<div class="wl verse" id="f6">
-<em class="author-emphasis">„Nie stargam cię ja — nie! — Ja, u-wydatnię</em>!...”</div>
+<em class="author-emphasis">„Nie stargam cię ja — nie! — Ja, u-wydatnię</em>!…”</div>
</div></div>
-\r
-\r
Między nami nic nie było!\r
Żadnych zwierzeń, wyznań żadnych!\r
Nic nas z sobą nie łączyło —\r
# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
#
import unittest
-from librarian import NoDublinCore
from librarian.builders import builders
-from librarian.parser import WLDocument as LegacyWLDocument
from librarian.document import WLDocument
from .utils import get_fixture
class TextTests(unittest.TestCase):
maxDiff = None
- def test_transform_legacy(self):
- expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
-
- text = LegacyWLDocument.from_file(
- get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
- ).as_text().get_bytes().decode('utf-8')
-
- with open(expected_output_file_path, 'rb') as f:
- self.assertEqual(text, f.read().decode('utf-8'))
-
def test_transform(self):
expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
def test_transform_raw(self):
expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected_raw.txt')
- text = LegacyWLDocument.from_file(
- get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
- ).as_text(flags=['raw-text']).get_bytes().decode('utf-8')
+ text = WLDocument(
+ filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
+ ).build(builders['txt'], raw_text=True).get_bytes().decode('utf-8')
with open(expected_output_file_path, 'rb') as f:
self.assertEqual(text, f.read().decode('utf-8'))
-
- def test_no_dublincore(self):
- with self.assertRaises(NoDublinCore):
- LegacyWLDocument.from_file(
- get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
- ).as_text()
-
- def test_passing_parse_dublincore_to_transform(self):
- """Passing parse_dublincore=False to the constructor omits DublinCore parsing."""
- LegacyWLDocument.from_file(
- get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
- parse_dublincore=False,
- ).as_text()