fnp
/
librarian.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
release
[librarian.git]
/
src
/
librarian
/
builders
/
html.py
diff --git
a/src/librarian/builders/html.py
b/src/librarian/builders/html.py
index
f2177ae
..
5bbe76a
100644
(file)
--- a/
src/librarian/builders/html.py
+++ b/
src/librarian/builders/html.py
@@
-32,7
+32,6
@@
class HtmlBuilder:
self.header = etree.Element('h1')
self.footnotes = etree.Element('div', id='footnotes')
self.header = etree.Element('h1')
self.footnotes = etree.Element('div', id='footnotes')
- self.counters = defaultdict(lambda: 1)
self.nota_red = etree.Element('div', id='nota_red')
self.nota_red = etree.Element('div', id='nota_red')
@@
-71,8
+70,7
@@
class HtmlBuilder:
def build(self, document, element=None, **kwargs):
self.document = document
def build(self, document, element=None, **kwargs):
self.document = document
-
- self.assign_ids(self.document.tree)
+ self.document.assign_ids()
self.prepare_images()
if element is None:
self.prepare_images()
if element is None:
@@
-82,12
+80,6
@@
class HtmlBuilder:
self.postprocess(document)
return self.output()
self.postprocess(document)
return self.output()
- def assign_ids(self, tree):
- # Assign IDs depth-first, to account for any <numeracja> 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:
def prepare_images(self):
# Temporarily use the legacy method, before transitioning to external generators.
if self.gallery_path is None:
@@
-135,7
+127,7
@@
class HtmlBuilder:
if self.with_toc:
add_table_of_contents(self.tree)
if self.with_toc:
add_table_of_contents(self.tree)
- if self.counters['fn'] > 1:
+ if self.
document.
counters['fn'] > 1:
fnheader = etree.Element("h3")
fnheader.text = _("Footnotes")
self.footnotes.insert(0, fnheader)
fnheader = etree.Element("h3")
fnheader.text = _("Footnotes")
self.footnotes.insert(0, fnheader)
@@
-240,6
+232,8
@@
class AbstraktHtmlBuilder(HtmlBuilder):
def build(self, document, element=None, **kwargs):
if element is None:
element = document.tree.find('//abstrakt')
def build(self, document, element=None, **kwargs):
if element is None:
element = document.tree.find('//abstrakt')
+ if element is None:
+ return OutputFile.from_bytes(b'')
element.attrib['_force'] = '1'
return super().build(document, element, **kwargs)
element.attrib['_force'] = '1'
return super().build(document, element, **kwargs)