Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
Unreleased
----------

* **Documentation** [#137] Document the heading class migration for custom CSS selectors.
* **Bugfix** [#134] Improve support for external theme packages by using a ``get_scss_sources_path()`` convention.

- If needed, theme warnings can be suppressed via ``suppress_warnings = ["simplepdf.theme"]``.
Expand Down
28 changes: 28 additions & 0 deletions docs/css.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ If this is set to ``break``, then a page break will be introduced in front of th
:file: example.csv
:class: break

Heading classes
~~~~~~~~~~~~~~~
The internal toctree fix adds generated classes to level 1 and level 2 headings so that PDF-specific CSS can
target headings and their anchors.

Each ``h1`` and ``h2`` receives a stable ``heading-N`` class, where ``N`` is the zero-based position of the
heading among headings with the same tag name. The first heading of each tag name also receives ``first``.

The ``even``, ``odd`` and ``last`` classes are applied to the anchor ``span`` immediately before the heading's
``section`` instead of to the heading element itself. The span also receives ``anchor-before-heading``.

If custom CSS targets the old heading selectors, update them to select through the anchor span:

.. code-block:: css

/* Old selector. */
h2.even {
break-before: page;
}

/* New selector. */
span.anchor-before-heading.even + section h2 {
break-before: page;
}

The same pattern applies to ``odd`` and ``last`` selectors, for example
``span.anchor-before-heading.last + section h2``.

.. _css_orientation:

Page Orientation
Expand Down