From 814083adcf7438edc83698395887e61275ee750b Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Tue, 8 Apr 2025 13:36:49 -0600 Subject: [PATCH 1/7] use assembled source for the source_element() method, to work with versions --- pretext/project/__init__.py | 38 +++++++++++++++++----- pretext/resources/resource_hash_table.json | 12 +++++++ templates/.gitignore | 2 +- templates/codechat_config.yaml | 2 +- templates/devcontainer.json | 2 +- templates/installLatex.sh | 2 +- templates/installPandoc.sh | 2 +- templates/installPretext.sh | 2 +- templates/installSage.sh | 2 +- templates/pretext-cli.yml | 2 +- templates/pretext-deploy.yml | 2 +- templates/project.ptx | 2 +- 12 files changed, 51 insertions(+), 19 deletions(-) diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index 8cbf4f96..998c6d93 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -346,12 +346,16 @@ def post_validate(self) -> None: raise ValueError( "Only one is allowed in a PreTeXt document." ) - d = d_list[0] - assert isinstance(d, str) - # Use the correct number of `../` to undo the project's `output-dir`, so the output from the build is located in the correct directory of `published/document-id`. - self.output_dir = Path( - f"{'../'*len(self._project.output_dir.parents)}published/{d}" - ) + # NB as of 2025-04-08, we are no longer setting the output directory automatically for + # Runestone targets. This must be managed by the project.ptx file or by a client script. + # The commented code below is how we used to do this. + + # d = d_list[0] + # assert isinstance(d, str) + # # Use the correct number of `../` to undo the project's `output-dir`, so the output from the build is located in the correct directory of `published/document-id`. + # self.output_dir = Path( + # f"{'../'*len(self._project.output_dir.parents)}published/{d}" + # ) else: raise ValueError( "The must be defined for the Runestone format." @@ -360,12 +364,28 @@ def post_validate(self) -> None: def source_abspath(self) -> Path: return self._project.source_abspath() / self.source - def source_element(self) -> ET._Element: + def original_source_element(self) -> ET._Element: + """ + Returns the root element of the original source document without running through pretext assembly. + """ source_doc = ET.parse(self.source_abspath()) for _ in range(25): source_doc.xinclude() + print("Type of source_doc: ", type(source_doc)) return source_doc.getroot() + def source_element(self) -> ET._XSLTResultTree: + """ + Returns the root element for the assembled source, after processing with the "version-only" assembly. + """ + assembled = core.assembly_internal( + xml=self.source_abspath(), + pub_file=self.publication_abspath().as_posix(), + stringparams=self.stringparams.copy(), + method="version", + ) + return assembled.getroot() + def publication_abspath(self) -> Path: return self._project.publication_abspath() / self.publication @@ -446,7 +466,7 @@ def load_asset_table(self) -> pt.AssetTable: def generate_asset_table(self) -> pt.AssetTable: """ - Returns a hash table (dictionary) with keys the asset types present in the current target's source, each with value a hash of all the assets of that type. + Returns a hash table (dictionary) with keys the asset types present in the current target's *assembled* source, each with value a hash of all the assets of that type. ex: {latex-image: , asymptote: }. NOTE: This is a change in behavior starting in 2.13; previously the keys were dictionaries mapping xml:id's to hashes of individual assets. @@ -455,7 +475,7 @@ def generate_asset_table(self) -> pt.AssetTable: ns = {"pf": "https://prefigure.org"} for asset in constants.ASSET_TO_XPATH.keys(): # everything else can be updated individually. - # get all the nodes for the asset attribute + # get all the nodes for the asset attribute (using assembled source) source_assets = self.source_element().xpath( constants.ASSET_TO_XPATH[asset], namespaces=ns ) diff --git a/pretext/resources/resource_hash_table.json b/pretext/resources/resource_hash_table.json index cebfdc73..e674cc26 100644 --- a/pretext/resources/resource_hash_table.json +++ b/pretext/resources/resource_hash_table.json @@ -116,5 +116,17 @@ "installPandoc.sh": "0dfd2cf2455efeff82293ba2b3724bc94e20620ed9f87c4cd3ee967d0dedd076", "installLatex.sh": "89fc36da1ac5bf3c79e70990d760f288b94afb71dac03f0651424efbf55663aa", "installSage.sh": "7f2b791271aaf21a0b6c742e9758d4f131b59216c261902fe43c8461143cb407" + }, + "2.16.2": { + "project.ptx": "72285565f5bcd94eedb2b91f88cea37e7af21604bcb5eb9e99c286fe1291ebb3", + "codechat_config.yaml": "2fb7c39582a71b878d6d5105b5ac5dae51d5c4f4ee3354f50ba0a9dfe80ce70c", + ".gitignore": "c9dd727d2357c9c7d8022a688ae71f17d17aa2d70bccf978cb366b49b43feda2", + "devcontainer.json": "ae45a61196b3121a5644ddf4dec62843a9178185e6f9cd8ed4d6e0bcaa6f24b9", + "pretext-cli.yml": "b9bb9deb5e64ed8fa2fe472688029ae4f77731cf6a006a5c58c80c55bdb85131", + "pretext-deploy.yml": "dbf18a18cf30b9301fff84890ad99334ba08f6ab0cdfa88b5d0cb233fc378c60", + "installPretext.sh": "0bab8bf900bd81c83039656740082742afea4c99f577324d5498ae7e8644073d", + "installPandoc.sh": "b36cfab7b0a9c0536777aea982e466186184d0f317867f598e06709bf4332b75", + "installLatex.sh": "1fa5ba1cbf5d7f0d5dc71e988558281fc16e4a131b09ae9fe917b5c692e08a47", + "installSage.sh": "797938aeab7a1f2e109e40a3f116f0c66fe96e49af59968833ede70a786130ff" } } \ No newline at end of file diff --git a/templates/.gitignore b/templates/.gitignore index f8c81b9a..cd0a7826 100644 --- a/templates/.gitignore +++ b/templates/.gitignore @@ -1,4 +1,4 @@ -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. # # Boilerplate list of files in a PreTeXt project for git to ignore diff --git a/templates/codechat_config.yaml b/templates/codechat_config.yaml index 9eb86658..75f8c584 100644 --- a/templates/codechat_config.yaml +++ b/templates/codechat_config.yaml @@ -1,4 +1,4 @@ -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. # ############################################################# diff --git a/templates/devcontainer.json b/templates/devcontainer.json index 0aaa72f4..b6dc76b5 100644 --- a/templates/devcontainer.json +++ b/templates/devcontainer.json @@ -1,4 +1,4 @@ -// This file was automatically generated with PreTeXt 2.16.1. +// This file was automatically generated with PreTeXt 2.16.2. // If you modify this file, PreTeXt will no longer automatically update it. // ////////////////////////////////////////////////////////////// diff --git a/templates/installLatex.sh b/templates/installLatex.sh index 41da148f..e58b90f5 100644 --- a/templates/installLatex.sh +++ b/templates/installLatex.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. # We use TinyTeX (https://yihui.org/tinytex/) diff --git a/templates/installPandoc.sh b/templates/installPandoc.sh index 063e4300..486a2622 100644 --- a/templates/installPandoc.sh +++ b/templates/installPandoc.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. wget https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb -O pandoc.deb diff --git a/templates/installPretext.sh b/templates/installPretext.sh index a3700490..ba2d11b8 100644 --- a/templates/installPretext.sh +++ b/templates/installPretext.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. sudo apt-get update diff --git a/templates/installSage.sh b/templates/installSage.sh index b37999bc..7e6c7bdd 100644 --- a/templates/installSage.sh +++ b/templates/installSage.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. # Conda should already be installed in the codespace. We need to add the conda-forge channel diff --git a/templates/pretext-cli.yml b/templates/pretext-cli.yml index 88348c6b..725f7cb7 100644 --- a/templates/pretext-cli.yml +++ b/templates/pretext-cli.yml @@ -1,4 +1,4 @@ -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. # # This workflow file can be used to automatically build a project and create diff --git a/templates/pretext-deploy.yml b/templates/pretext-deploy.yml index 717f4980..805e2a84 100644 --- a/templates/pretext-deploy.yml +++ b/templates/pretext-deploy.yml @@ -1,4 +1,4 @@ -# This file was automatically generated with PreTeXt 2.16.1. +# This file was automatically generated with PreTeXt 2.16.2. # If you modify this file, PreTeXt will no longer automatically update it. # diff --git a/templates/project.ptx b/templates/project.ptx index 97e2a1a6..23865444 100644 --- a/templates/project.ptx +++ b/templates/project.ptx @@ -1,5 +1,5 @@ - + From 517d158c6e2bca1affe07c257c3c0c823de6606c Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Tue, 8 Apr 2025 14:00:33 -0600 Subject: [PATCH 2/7] fix types --- pretext/project/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index 998c6d93..9d0bc122 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -374,7 +374,7 @@ def original_source_element(self) -> ET._Element: print("Type of source_doc: ", type(source_doc)) return source_doc.getroot() - def source_element(self) -> ET._XSLTResultTree: + def source_element(self) -> ET._Element: """ Returns the root element for the assembled source, after processing with the "version-only" assembly. """ From 412dcf6f16be282148f69d78aac84fafb501bc71 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Wed, 9 Apr 2025 17:34:45 +0000 Subject: [PATCH 3/7] update core commit and package for codespace latex --- pretext/__init__.py | 2 +- templates/installLatex.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pretext/__init__.py b/pretext/__init__.py index 3b14fe8f..af5b169e 100644 --- a/pretext/__init__.py +++ b/pretext/__init__.py @@ -18,7 +18,7 @@ VERSION = get_version("pretext", Path(__file__).parent.parent) -CORE_COMMIT = "7017d8fcc7005984ffc7fad81d0a37062a529a9d" +CORE_COMMIT = "2c3fda724738cabba04c28378f91a64a72a0e7c2" def activate() -> None: diff --git a/templates/installLatex.sh b/templates/installLatex.sh index e58b90f5..17980157 100644 --- a/templates/installLatex.sh +++ b/templates/installLatex.sh @@ -6,7 +6,7 @@ # We use TinyTeX (https://yihui.org/tinytex/) wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh -tlmgr install adjustbox amscdx bold-extra braket bussproofs cancel carlisle cases chessfss circuitikz colortbl enumitem extpfeil fontawesome5 fontaxes gensymb imakeidx kastrup lambda-lists listings listingsutf8 marvosym mathalpha mathtools menukeys mhchem microtype musicography newpx newtx nicematrix pdfcol pdfpages pdflscape pgfplots phaistos physics polyglossia pstricks realscripts relsize siunitx skak skaknew smartdiagram snapshot stmaryrd tcolorbox tikzfill titlesec txfonts ulem upquote was xfrac xltxtra xpatch xstring +tlmgr install adjustbox amscdx bold-extra braket bussproofs cancel carlisle cases chessfss circuitikz colortbl enumitem extpfeil fontawesome5 fontaxes gensymb imakeidx jknapltx kastrup lambda-lists listings listingsutf8 marvosym mathalpha mathtools menukeys mhchem microtype musicography newpx newtx nicematrix pdfcol pdfpages pdflscape pgfplots phaistos physics polyglossia pstricks realscripts relsize siunitx skak skaknew smartdiagram snapshot stmaryrd tcolorbox tikzfill titlesec txfonts ulem upquote was xfrac xltxtra xpatch xstring tlmgr path add From 40fcd52e395bf034c8f964ba29617e464ae4966e Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Wed, 9 Apr 2025 17:47:26 +0000 Subject: [PATCH 4/7] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c6f937..9676ba89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,14 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change ## [Unreleased] +### Changed + +- The CLI now uses your assembled source in case you use "versions" for checking for some source errors and deciding whether assets must be regenerated. For example, if you change an asset in a component that is not part of a version, it will not trigger rebuilding all assets. + +### Fixed + +- Fixed a bug with the denver theme that displayed some tasks with their headings not inline. + ## [2.16.1] - 2025-04-08 Includes updates to core through commit: [7017d8f](https://github.com/PreTeXtBook/pretext/commit/7017d8fcc7005984ffc7fad81d0a37062a529a9d) From 73e9aa1f77200ec2e2d593425f7222879627af0f Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Wed, 9 Apr 2025 18:01:51 +0000 Subject: [PATCH 5/7] fix tests --- tests/test_project.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index e87929c7..84245ed7 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -97,12 +97,12 @@ def test_manifest_simple(tmp_path: Path) -> None: assert t_print.platform is None assert t_print.deploy_dir is None - t_rune = project.get_target("rs") - assert t_rune.format == "html" - assert t_rune.platform == "runestone" - assert t_rune.output_dir_abspath().resolve().relative_to( - project.abspath() - ) == Path("published/runestone-document-id") + # t_rune = project.get_target("rs") + # assert t_rune.format == "html" + # assert t_rune.platform == "runestone" + # assert t_rune.output_dir_abspath().resolve().relative_to( + # project.abspath() + # ) == Path("published/runestone-document-id") assert not project.has_target("foo") From 16c639cedef0ccaf395f0542ca8f07e8195770f3 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Wed, 9 Apr 2025 12:55:49 -0600 Subject: [PATCH 6/7] fix rs tests --- tests/test_project.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 84245ed7..34d2d341 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -97,12 +97,12 @@ def test_manifest_simple(tmp_path: Path) -> None: assert t_print.platform is None assert t_print.deploy_dir is None - # t_rune = project.get_target("rs") - # assert t_rune.format == "html" - # assert t_rune.platform == "runestone" - # assert t_rune.output_dir_abspath().resolve().relative_to( - # project.abspath() - # ) == Path("published/runestone-document-id") + t_rune = project.get_target("rs") + assert t_rune.format == "html" + assert t_rune.platform == "runestone" + assert t_rune.output_dir_abspath().resolve().relative_to( + project.abspath() + ) == Path("output/rs") assert not project.has_target("foo") @@ -121,10 +121,10 @@ def test_manifest_simple_build(tmp_path: Path) -> None: assert (prj_path / "output" / "web" / "index.html").exists() project.get_target("rs").build() assert ( - prj_path / "published" / "runestone-document-id" / "index.html" + prj_path / "output" / "rs" / "index.html" ).exists() assert ( - prj_path / "published" / "runestone-document-id" / "runestone-manifest.xml" + prj_path / "output" / "rs" / "runestone-manifest.xml" ).exists() if HAS_XELATEX: project.get_target("print").build() From feb86553dd2dae8c839d088fef8daa71fac54ff1 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Wed, 9 Apr 2025 13:05:13 -0600 Subject: [PATCH 7/7] format --- tests/test_project.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 34d2d341..27fb53b6 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -120,12 +120,8 @@ def test_manifest_simple_build(tmp_path: Path) -> None: project.get_target("web").build() assert (prj_path / "output" / "web" / "index.html").exists() project.get_target("rs").build() - assert ( - prj_path / "output" / "rs" / "index.html" - ).exists() - assert ( - prj_path / "output" / "rs" / "runestone-manifest.xml" - ).exists() + assert (prj_path / "output" / "rs" / "index.html").exists() + assert (prj_path / "output" / "rs" / "runestone-manifest.xml").exists() if HAS_XELATEX: project.get_target("print").build() assert (prj_path / "output" / "print" / "main.pdf").exists()