Skip to content

Commit e974ad5

Browse files
authored
Latex source saving (#1090)
* Improve latex and pdf building * add latex flag to keep latex source * remove extra managed directory copying
1 parent f8d1ca2 commit e974ad5

File tree

6 files changed

+22
-34
lines changed

6 files changed

+22
-34
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
99

1010
## [Unreleased]
1111

12+
### Added
13+
14+
- PDF targets built with `--latex` flag will include the latex source in the output directory.
15+
1216
## [2.31.0] - 2025-11-20
1317

1418
Includes updates to core through commit: [65231d1](https://github.com/PreTeXtBook/pretext/commit/65231d1891e6a60f9e9d4873520e5d3e849e59b3)

new-pretext-project1/logs/.fuse_hidden0006e26600000258

Lines changed: 0 additions & 13 deletions
This file was deleted.

new-pretext-project1/logs/.fuse_hidden0006e27000000230

Lines changed: 0 additions & 13 deletions
This file was deleted.

pretext/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
VERSION = get_version("pretext", Path(__file__).parent.parent)
2020

2121

22-
CORE_COMMIT = "65231d1891e6a60f9e9d4873520e5d3e849e59b3"
22+
CORE_COMMIT = "ce20f15d525f2d1e7a3c3fb8da3bb5fa9d16d3ee"
2323

2424

2525
def activate() -> None:

pretext/cli.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ def init(refresh: bool, files: List[str], system: bool) -> None:
482482
is_flag=True,
483483
help="Only build the theme for the target, without performing any other build or generate steps. (Themes are automatically built when building a target.)",
484484
)
485+
@click.option(
486+
"-l",
487+
"--latex",
488+
is_flag=True,
489+
help="When building a PDF, also place LaTeX source files in the output directory for inspection or manual compilation.",
490+
)
485491
@click.option(
486492
"-x",
487493
"--xmlid",
@@ -514,6 +520,7 @@ def build(
514520
generate: bool,
515521
no_generate: bool,
516522
theme: bool,
523+
latex: bool,
517524
xmlid: Optional[str],
518525
no_knowls: bool,
519526
deploys: bool,
@@ -627,7 +634,11 @@ def build(
627634
if xmlid is not None:
628635
log.info(f"with root of tree below {xmlid}")
629636
t.build(
630-
clean=clean, generate=not no_generate, xmlid=xmlid, no_knowls=no_knowls
637+
clean=clean,
638+
generate=not no_generate,
639+
xmlid=xmlid,
640+
no_knowls=no_knowls,
641+
latex=latex,
631642
)
632643
if t.format == "html" and t.compression is None:
633644
log.info(

pretext/project/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ def build(
665665
generate: bool = True,
666666
xmlid: t.Optional[str] = None,
667667
no_knowls: bool = False,
668+
latex: bool = False,
668669
) -> None:
669670
# Add cli.version to stringparams. Use only the major and minor version numbers.
670671
self.stringparams["cli.version"] = VERSION[: VERSION.rfind(".")]
@@ -776,20 +777,18 @@ def build(
776777
out_file=out_file,
777778
dest_dir=self.output_dir_abspath().as_posix(),
778779
method=self.latex_engine,
780+
outputs="all" if latex else "pdf",
779781
)
780782
elif self.format == Format.LATEX:
781-
core.latex(
783+
core.pdf(
782784
xml=self.source_abspath(),
783785
pub_file=self.publication_abspath().as_posix(),
784786
stringparams=stringparams_copy,
785787
extra_xsl=custom_xsl,
786788
out_file=out_file,
787789
dest_dir=self.output_dir_abspath().as_posix(),
788-
)
789-
utils.manage_directories(
790-
self.output_dir_abspath(),
791-
external_abs=self.external_dir_abspath(),
792-
generated_abs=self.generated_dir_abspath(),
790+
method=self.latex_engine,
791+
outputs="prebuild",
793792
)
794793
elif self.format == Format.EPUB:
795794
utils.mjsre_npm_install()

0 commit comments

Comments
 (0)