Skip to content

v2.6.8

Choose a tag to compare

@TobiasGlaubach TobiasGlaubach released this 09 Jun 15:22
· 22 commits to main since this release
b7f50bd

Summary

This branch introduces extensive improvements across templating, PDF engine handling, JSON serialization, logging and new Typst support. Key changes include:

Templating Engine Overhaul (templating.py)

  • Migrated from DocTemplate monolithic class to TemplateDirSource for template loading/management.
  • Added engine auto-detection (determine_engine_from_template) for html, typ, and tex backends based on file extension or source markers (<html>, #set , \documentclass).
  • Unified handle_template() function replaces _handle_template across all backends.
  • Typed undeclared variables as jinja2.Undefined instead of None for cleaner JSON serialization.

Typst Backend Support (ex_typst.py, base.typ.j2)

  • New Typst template engine with compilation via typst Python package.
  • Unified logging via util.log instead of standalone logging.basicConfig.
  • Added CommonJSONEncoder for Typst-safe JSON serialization with LaTeX math support.

PDF Engine Auto-Detection (core.py)

  • Doc.to_pdf() now auto-detects the PDF engine from the template type (tex/typ/html) or pydocmaker config.
  • Added ALLOWED_ENGINES_PDF config (tex, latex, typst, typ, word, libreoffice, pandoc).
  • Re-enabled overwrite protection for set_template_to_meta with configurable on_exist modes (fail, overwrite, skip).

JSON Serialization (util.py)

  • Added CommonJSONEncoder and MyJSONDecoder for handling Undefined objects, Path, datetime, set, numpy, and pandas types in JSON.
  • Added remove_undefined() to filter jinja2.Undefined values from template params before rendering.
  • Added limit_len() helper for log output truncation.

Logging Centralization

  • All orphan logging.basicConfig() calls removed from individual backend modules.
  • Single centralized logger in util.py with format: [%(asctime)s | %(levelname)-5s | %(name)s] %(message)s.

Typst Report Template Simplified (report.typ.j2, staged)

  • Removed heading-font and body-font parameters — fonts now use defaults system-wide.
  • Removed Vollkorn-specific grey-value workaround (fill: if body-font == "Vollkorn" {luma(50)}).
  • This produces cleaner default output without font configuration overhead.

Other Fixes

  • Doc.to_json() now uses CommonJSONEncoder.
  • Doc.load_json() now uses MyJSONDecoder.
  • Doc.add_meta() files_to_upload handling consolidated — refactored merge logic eliminates duplicate code across on_exist branches.
  • Added Doc.dumps() alias for to_json().
  • Fixed attach empty-bincheck for Word attachments (ex_docx.py).
  • Fixed dict input mapping for Typeform binary params.
  • Updated .params.json files to use MyJSONDecoder.

Files Changed (35 files, +1926 / -787 lines)

  • 1 staged: src/pydocmaker/templates/report.typ.j2
  • 16+ Python source files across core.py, templating.py, util.py, backend/ex_*.py, backend/pandoc_api.py, backend/pdf_maker_tex.py
  • 4 notebook docs updated
  • 15+ binary/sample output files regenerated

Suggested release title: v2.6.8 — Typst support, templating engine overhaul, JSON serialization improvements