Skip to content

Add hook to manipulate HTML#128

Draft
jdillard wants to merge 1 commit intouseblocks:mainfrom
jdillard:html-hook
Draft

Add hook to manipulate HTML#128
jdillard wants to merge 1 commit intouseblocks:mainfrom
jdillard:html-hook

Conversation

@jdillard
Copy link

@jdillard jdillard commented Jan 28, 2026

Adds a new configuration option that allows users to specify a Python function to manipulate the HTML (via
BeautifulSoup) before PDF generation.

Usage:

# conf.py
simplepdf_html_hook = "./hooks/pdf_hook.py:customize_html"

# hooks/pdf_hook.py
def customize_html(soup, app):
    # manipulate soup
    return soup

Changes:

  • Added simplepdf_html_hook config option
  • Added _load_html_hook() and _execute_html_hook() methods
  • Refactored _toctree_fix() to work with BeautifulSoup objects directly
  • Added documentation in docs/configuration.rst

@jdillard jdillard marked this pull request as draft January 28, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant