Skip to content

Commit

Permalink
cli/aux-print: Improve pdf generation
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Marques <[email protected]>
  • Loading branch information
gastmaier committed Dec 13, 2024
1 parent 02763ed commit 1874281
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
15 changes: 13 additions & 2 deletions adi_doctools/cli/aux_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,20 @@ def sanitize_singlehtml(file) -> str:

bwrap = root.xpath("//div[@class='bodywrapper']")[0]

# Remove first H1
# Remove first H1 and replace with break-before
# if next if not a section (e.g. introduction)
h1_ = bwrap.xpath(".//h1")[0]
h1_.getparent().remove(h1_)
e_p = h1_.getparent()
e_n = h1_.getnext()
if e_n.tag != 'section':
if 'class' in e_n.attrib and "toctree-wrapper" in e_n.attrib['class']:
pass
else:
ele_break = etree.Element("span")
ele_break.attrib['class'] = "break-before"
e_p.insert(e_p.index(h1_), ele_break)
e_p.remove(h1_)


# Add description
ele_desc = etree.Element("span")
Expand Down
2 changes: 1 addition & 1 deletion adi_doctools/theme/cosmic/style/element.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ img {
.break-after {
break-after: always;
}
.break-before {
.break-before, h2 {
break-before: always;
}
}
Expand Down
1 change: 0 additions & 1 deletion adi_doctools/theme/cosmic/style/weasyprint.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@

h2 {
string-set: heading content();
break-before: always;
}

footer {
Expand Down
3 changes: 0 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on the directives and roles packaged on this repository.
And read the :ref:`cli` for information about the command line interface
provided by Doctools.

Contents
===============================================================================

.. toctree::
:maxdepth: 1

Expand Down

0 comments on commit 1874281

Please sign in to comment.