From 318d79c6ec02163ec898a66723055da25837346a Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 12 Feb 2020 13:30:24 +0100 Subject: [PATCH 1/1] Add swappable CSS for HTML previews. --- librarian/html.py | 7 +++++-- librarian/xslt/book2html.xslt | 9 +++++---- scripts/book2html | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) 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, -- 2.20.1