v2.6.8
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
DocTemplatemonolithic class toTemplateDirSourcefor template loading/management. - Added engine auto-detection (
determine_engine_from_template) forhtml,typ, andtexbackends based on file extension or source markers (<html>,#set,\documentclass). - Unified
handle_template()function replaces_handle_templateacross all backends. - Typed undeclared variables as
jinja2.Undefinedinstead ofNonefor cleaner JSON serialization.
Typst Backend Support (ex_typst.py, base.typ.j2)
- New Typst template engine with compilation via
typstPython package. - Unified logging via
util.loginstead of standalonelogging.basicConfig. - Added
CommonJSONEncoderfor 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_PDFconfig (tex,latex,typst,typ,word,libreoffice,pandoc). - Re-enabled overwrite protection for
set_template_to_metawith configurableon_existmodes (fail,overwrite,skip).
JSON Serialization (util.py)
- Added
CommonJSONEncoderandMyJSONDecoderfor handlingUndefinedobjects,Path,datetime,set,numpy, andpandastypes in JSON. - Added
remove_undefined()to filterjinja2.Undefinedvalues 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.pywith format:[%(asctime)s | %(levelname)-5s | %(name)s] %(message)s.
Typst Report Template Simplified (report.typ.j2, staged)
- Removed
heading-fontandbody-fontparameters — 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 usesCommonJSONEncoder.Doc.load_json()now usesMyJSONDecoder.Doc.add_meta()files_to_uploadhandling consolidated — refactored merge logic eliminates duplicate code acrosson_existbranches.- Added
Doc.dumps()alias forto_json(). - Fixed
attachempty-bincheck for Word attachments (ex_docx.py). - Fixed dict input mapping for Typeform binary params.
- Updated
.params.jsonfiles to useMyJSONDecoder.
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