From 83a5748aaafc9d93dd8326efae02e2524fdeac93 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Sat, 22 Nov 2025 20:07:01 -0700 Subject: [PATCH 1/3] Improve latex and pdf building --- CHANGELOG.md | 4 ++++ .../logs/.fuse_hidden0006e26600000258 | 13 ------------- .../logs/.fuse_hidden0006e27000000230 | 13 ------------- pretext/__init__.py | 2 +- pretext/project/__init__.py | 5 ++++- 5 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 new-pretext-project1/logs/.fuse_hidden0006e26600000258 delete mode 100644 new-pretext-project1/logs/.fuse_hidden0006e27000000230 diff --git a/CHANGELOG.md b/CHANGELOG.md index db577afd..7673f8ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change ## [Unreleased] +### Added + +- PDF targets built with `-v debug` will include the latex source in the output directory. + ## [2.31.0] - 2025-11-20 Includes updates to core through commit: [65231d1](https://github.com/PreTeXtBook/pretext/commit/65231d1891e6a60f9e9d4873520e5d3e849e59b3) diff --git a/new-pretext-project1/logs/.fuse_hidden0006e26600000258 b/new-pretext-project1/logs/.fuse_hidden0006e26600000258 deleted file mode 100644 index 3a7aac38..00000000 --- a/new-pretext-project1/logs/.fuse_hidden0006e26600000258 +++ /dev/null @@ -1,13 +0,0 @@ -INFO : Since no target was supplied, we will use "slides". - -INFO : Now preparing local server to preview your project directory `/files/GitHub/dev/pretext-cli/new-pretext-project`. -INFO : (Reminder: use `pretext deploy` to deploy your built project to a public -INFO : GitHub Pages site that can be shared with readers who cannot access your -INFO : personal computer.) -INFO : -INFO : starting server ... -INFO : setting up PreTeXt web server ... -INFO : Added pretext web server entry 32a890857c 528346 8128 localhost - -INFO : Server will soon be available at http://localhost:8128 -INFO : Opening browser for target `slides` at http://localhost:8128/output/slides diff --git a/new-pretext-project1/logs/.fuse_hidden0006e27000000230 b/new-pretext-project1/logs/.fuse_hidden0006e27000000230 deleted file mode 100644 index 341cf8a2..00000000 --- a/new-pretext-project1/logs/.fuse_hidden0006e27000000230 +++ /dev/null @@ -1,13 +0,0 @@ -INFO : Since no target was supplied, we will use "slides". - -INFO : Now preparing local server to preview your project directory `/files/GitHub/dev/pretext-cli/new-pretext-project`. -INFO : (Reminder: use `pretext deploy` to deploy your built project to a public -INFO : GitHub Pages site that can be shared with readers who cannot access your -INFO : personal computer.) -INFO : -INFO : starting server ... -INFO : setting up PreTeXt web server ... -INFO : Added pretext web server entry 32a890857c 528769 8129 localhost - -INFO : Server will soon be available at http://localhost:8129 -INFO : Opening browser for target `slides` at http://localhost:8129/output/slides diff --git a/pretext/__init__.py b/pretext/__init__.py index cd8b723b..1dbb48d8 100644 --- a/pretext/__init__.py +++ b/pretext/__init__.py @@ -19,7 +19,7 @@ VERSION = get_version("pretext", Path(__file__).parent.parent) -CORE_COMMIT = "65231d1891e6a60f9e9d4873520e5d3e849e59b3" +CORE_COMMIT = "ce20f15d525f2d1e7a3c3fb8da3bb5fa9d16d3ee" def activate() -> None: diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index f794205b..cffe8b0d 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -776,15 +776,18 @@ def build( out_file=out_file, dest_dir=self.output_dir_abspath().as_posix(), method=self.latex_engine, + outputs="all" if log.isEnabledFor(logging.DEBUG) else "pdf", ) elif self.format == Format.LATEX: - core.latex( + core.pdf( xml=self.source_abspath(), pub_file=self.publication_abspath().as_posix(), stringparams=stringparams_copy, extra_xsl=custom_xsl, out_file=out_file, dest_dir=self.output_dir_abspath().as_posix(), + method=self.latex_engine, + outputs="prebuild", ) utils.manage_directories( self.output_dir_abspath(), From 684ed2a1867acbff0248242a41cb60e7d15727a1 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Sat, 22 Nov 2025 20:14:07 -0700 Subject: [PATCH 2/3] add latex flag to keep latex source --- CHANGELOG.md | 2 +- pretext/cli.py | 13 ++++++++++++- pretext/project/__init__.py | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7673f8ab..9ef08ab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change ### Added -- PDF targets built with `-v debug` will include the latex source in the output directory. +- PDF targets built with `--latex` flag will include the latex source in the output directory. ## [2.31.0] - 2025-11-20 diff --git a/pretext/cli.py b/pretext/cli.py index 75bfabf9..a7b04723 100644 --- a/pretext/cli.py +++ b/pretext/cli.py @@ -482,6 +482,12 @@ def init(refresh: bool, files: List[str], system: bool) -> None: is_flag=True, help="Only build the theme for the target, without performing any other build or generate steps. (Themes are automatically built when building a target.)", ) +@click.option( + "-l", + "--latex", + is_flag=True, + help="When building a PDF, also place LaTeX source files in the output directory for inspection or manual compilation.", +) @click.option( "-x", "--xmlid", @@ -514,6 +520,7 @@ def build( generate: bool, no_generate: bool, theme: bool, + latex: bool, xmlid: Optional[str], no_knowls: bool, deploys: bool, @@ -627,7 +634,11 @@ def build( if xmlid is not None: log.info(f"with root of tree below {xmlid}") t.build( - clean=clean, generate=not no_generate, xmlid=xmlid, no_knowls=no_knowls + clean=clean, + generate=not no_generate, + xmlid=xmlid, + no_knowls=no_knowls, + latex=latex, ) if t.format == "html" and t.compression is None: log.info( diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index cffe8b0d..b146485a 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -665,6 +665,7 @@ def build( generate: bool = True, xmlid: t.Optional[str] = None, no_knowls: bool = False, + latex: bool = False, ) -> None: # Add cli.version to stringparams. Use only the major and minor version numbers. self.stringparams["cli.version"] = VERSION[: VERSION.rfind(".")] @@ -776,7 +777,7 @@ def build( out_file=out_file, dest_dir=self.output_dir_abspath().as_posix(), method=self.latex_engine, - outputs="all" if log.isEnabledFor(logging.DEBUG) else "pdf", + outputs="all" if latex else "pdf", ) elif self.format == Format.LATEX: core.pdf( From 00f156a41938670b5dae7121cbf62893bbb75149 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Sat, 22 Nov 2025 20:32:44 -0700 Subject: [PATCH 3/3] remove extra managed directory copying --- pretext/project/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index b146485a..6a7f00de 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -790,11 +790,6 @@ def build( method=self.latex_engine, outputs="prebuild", ) - utils.manage_directories( - self.output_dir_abspath(), - external_abs=self.external_dir_abspath(), - generated_abs=self.generated_dir_abspath(), - ) elif self.format == Format.EPUB: utils.mjsre_npm_install() core.epub(