diff --git a/CHANGELOG.md b/CHANGELOG.md index f5dfc6e6..127331a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change ## [Unreleased] +### Added + +- The `latex-source` attribute, set to anything except "no", on a target with format `pdf` will copy latex source files to output directory. + ## [2.32.0] - 2025-11-23 Includes updates to core through commit: [ce20f15](https://github.com/PreTeXtBook/pretext/commit/ce20f15d525f2d1e7a3c3fb8da3bb5fa9d16d3ee) diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index 6a7f00de..9c298622 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -132,6 +132,16 @@ class Target(pxml.BaseXmlModel, tag="target", search_mode=SearchMode.UNORDERED): latex_engine: LatexEngine = pxml.attr( name="latex-engine", default=LatexEngine.XELATEX ) + # Flag to indicate whether to include LaTeX source files in the output directory when building a PDF target. + latex_source: t.Optional[str] = pxml.attr(name="latex-source", default=None) + + @field_validator("latex_source") + @classmethod + def latex_source_validator(cls, v: t.Optional[str]) -> bool: + if v is None: + return False + return v.lower() != "no" + braille_mode: BrailleMode = pxml.attr( name="braille-mode", default=BrailleMode.EMBOSS ) @@ -769,6 +779,9 @@ def build( ) log.debug(e, exc_info=True) elif self.format == Format.PDF: + # Include latex source files if requested. + if self.latex_source: + latex = True core.pdf( xml=self.source_abspath(), pub_file=self.publication_abspath().as_posix(), @@ -777,7 +790,7 @@ def build( out_file=out_file, dest_dir=self.output_dir_abspath().as_posix(), method=self.latex_engine, - outputs="all" if latex else "pdf", + outputs="all" if latex else "pdf-only", ) elif self.format == Format.LATEX: core.pdf(