From: Radek Czajka Date: Wed, 12 Feb 2020 12:30:24 +0000 (+0100) Subject: Add swappable CSS for HTML previews. X-Git-Tag: 1.8~2 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/318d79c6ec02163ec898a66723055da25837346a?ds=sidebyside Add swappable CSS for HTML previews. --- diff --git a/librarian/html.py b/librarian/html.py index ed7b4d6..096e399 100644 --- a/librarian/html.py +++ b/librarian/html.py @@ -45,7 +45,7 @@ def transform_abstrakt(abstrakt_element): return re.sub(']*>', '', html) -def transform(wldoc, stylesheet='legacy', options=None, flags=None): +def transform(wldoc, stylesheet='legacy', options=None, flags=None, css=None): """Transforms the WL document to XHTML. If output_filename is None, returns an XML, @@ -71,7 +71,10 @@ def transform(wldoc, stylesheet='legacy', options=None, flags=None): if not options: options = {} options.setdefault('gallery', "''") - result = document.transform(style, **options) + + 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): diff --git a/librarian/xslt/book2html.xslt b/librarian/xslt/book2html.xslt index e670fb0..3b094ac 100644 --- a/librarian/xslt/book2html.xslt +++ b/librarian/xslt/book2html.xslt @@ -19,10 +19,11 @@ Książka z serwisu WolneLektury.pl - - + + + + + diff --git a/scripts/book2html b/scripts/book2html index f6d459d..02d542c 100755 --- a/scripts/book2html +++ b/scripts/book2html @@ -19,6 +19,9 @@ class Book2Html(Book2Anything): action='store_false', default=True, help='output raw text for use in templates') ] + transform_options = [ + Option('--css', dest='css') + ] parser_options = [ Option('-i', '--ignore-dublin-core', dest='parse_dublincore', action='store_false', default=True,