Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pretext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

VERSION = get_version("pretext", Path(__file__).parent.parent)

CORE_COMMIT = "7017d8fcc7005984ffc7fad81d0a37062a529a9d"
CORE_COMMIT = "2c3fda724738cabba04c28378f91a64a72a0e7c2"


def activate() -> None:
Expand Down
38 changes: 29 additions & 9 deletions pretext/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,16 @@ def post_validate(self) -> None:
raise ValueError(
"Only one <document-id> 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 <document-id> must be defined for the Runestone format."
Expand All @@ -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._Element:
"""
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

Expand Down Expand Up @@ -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: <hash>, asymptote: <hash>}.

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.
Expand All @@ -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
)
Expand Down
12 changes: 12 additions & 0 deletions pretext/resources/resource_hash_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion templates/.gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/codechat_config.yaml
Original file line number Diff line number Diff line change
@@ -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.
#
#############################################################
Expand Down
2 changes: 1 addition & 1 deletion templates/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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.
//
//////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions templates/installLatex.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/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/)
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

Expand Down
2 changes: 1 addition & 1 deletion templates/installPandoc.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/installPretext.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/installSage.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/pretext-cli.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/pretext-deploy.yml
Original file line number Diff line number Diff line change
@@ -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.
#

Expand Down
2 changes: 1 addition & 1 deletion templates/project.ptx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This file was automatically generated by PreTeXt 2.16.1. -->
<!-- This file was automatically generated by PreTeXt 2.16.2. -->
<!-- If you modify this file, PreTeXt will no longer automatically update it.-->

<!-- This file, the project manifest, provides the overall configuration for your PreTeXt project. To edit the content of your document, open `source/main.ptx`. See https://pretextbook.org/doc/guide/html/processing-CLI.html#cli-project-manifest. -->
Expand Down
10 changes: 3 additions & 7 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_manifest_simple(tmp_path: Path) -> None:
assert t_rune.platform == "runestone"
assert t_rune.output_dir_abspath().resolve().relative_to(
project.abspath()
) == Path("published/runestone-document-id")
) == Path("output/rs")

assert not project.has_target("foo")

Expand All @@ -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 / "published" / "runestone-document-id" / "index.html"
).exists()
assert (
prj_path / "published" / "runestone-document-id" / "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()
Expand Down