Use PTX genreated chapter numbers when processing manifest#1313
Merged
bnmnetp merged 1 commit intoJul 21, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Runestone issue #1310 where assignment reading chapter numbers are off by one, by switching chapter/subchapter numbering to use the PreTeXt (PTX) manifest-provided <number> values rather than purely sequential counters.
Changes:
- Use manifest
<number>forchapters.chapter_numwhen processing chapters. - Parse manifest subchapter numbers like
"1.1"to store/display only the subchapter portion (e.g.,"1"). - Rename internal counters for clarity (
chapter_counter,subchap_counter).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+690
to
+692
| cnum = chapter.find("./number").text | ||
| if not cnum: | ||
| cnum = "" | ||
| cnum = chap_counter |
Comment on lines
+756
to
+757
| else: | ||
| scnum = subchap_counter |
| sub_chapter_label=subchapter.find("./id").text, | ||
| skipreading="F", | ||
| sub_chapter_num=subchap_num, | ||
| sub_chapter_num=scnum, |
ascholerChemeketa
force-pushed
the
issue-1310-fix
branch
from
July 21, 2026 17:08
84a3812 to
4b0b6d6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
components/rsptx/build_tools/core.py:694
chapter.find("./number").textcan raiseAttributeErrorwhen the<number>element is missing, andint(cnum_text)can raiseValueErrorif the manifest contains whitespace or a non-integer value. Since the code already has a fallback to the counter, it should safely read and parse the text (including stripping) and fall back on parse errors.
cnum_text = chapter.find("./number").text
if not cnum_text:
cnum = chap_counter
else:
cnum = int(cnum_text)
components/rsptx/build_tools/core.py:756
subchapter.find("./number").textcan raiseAttributeErrorif the<number>element is missing, and theint()conversion will raise if the value includes unexpected whitespace or a non-integer (e.g., malformedx.y). Usefindtext()+strip()and fall back tosubchap_counteron parse errors to avoid failing the whole manifest load.
scnum_text = subchapter.find("./number").text
if scnum_text:
# subchapter numbers are in manifest as "1.1", "1.2", etc.
# strip off the chapter number and just keep the subchapter number
if "." in scnum_text:
Contributor
Author
|
Pushed with updates for Copilot review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #1310