Repository navigation
Improvements for journal support including CSL specification - #3219
oscarlevin wants to merge 19 commits into
Conversation
|
Just a short note, no need to change anything yet, there will be more later. I think maybe a development road map should just become an issue on GitHub. It could have tasks, and we could just let our assistants manage it. Not sure I want a lot of AI messing-about in the repo, and I'm not sure diffs on the git history would be the best way to see history/progress. My work converting PDFs of research articles keeps turning up subtle bugs (excellent!) and I'm just having those sessions make issues. Then I can point a development assistant to the issue for the real work. I think a roadmap could be utilized the same way. Tangential: where/how we get the CSL style files has been a big question in my mind, so I will take some time to scrutinize this one carefully. |
|
I had Claude do a review of this, suggesting that the Python looked to me to be more complicated than perhaps necessary. This is addressed in the review.
|
|
Thanks, Oscar. Pulling a journal's CSL style is a good step, and several pieces here fix long-standing problems. I built the branch and ran each path, using a small article with three CSL-structured The journal's style doesn't reach a conversion
With
Adding the same style explicitly with The roadmap puts this resolution in the CLI, where a target's stringparams are assembled. Even if the CLI does that, the A missing references file still stops a conversionWith a CSL style named and no generated The Springer Nature class file arrives as a zipThe new URL ( The Python could be much smallerThe six new functions come to about 185 lines, plus changes to
There is a simpler arrangement. Let citeproc-py find the style. citeproc-py 0.10 already resolves a bare style name by trying a file path, then its one bundled style, then the Resolve the style name where every conversion already looks. That leaves the missing-file check as the one piece that needs Python, since XSLT 1.0 can't test whether a file exists. Like the style, it has to be set wherever conversions run. Documentation
Schema
Commits
What works well
Claude Opus 5.5, acting as a review assistant for Rob Beezer |
… archive as a zip Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ver its URL Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n a transform Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he publisher's generated directory Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssing or mismatched Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iteproc-py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o BibTeX style or command Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ats it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… citations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
792ec58 to
4be592f
Compare
|
Thanks, Rob, and thanks for the thorough review. I've rebuilt the branch on current master along the lines the review suggested, with two changes of detail explained below. The Python additions went from about 220 lines to about 45, and the PR is now 213 insertions across 18 files. What changed
Two places I went a different way1. The journal→style mapping lives in
The catch is that the ten AMS journals each repeat 2. The missing-file check isn't something each consumer has to set. Every transform, whether from the script, the CLI or another library user, goes through With that in place, assembly can test for the file itself. The test is the count you'd left commented out in Along the way, a new VerifiedI checked these with the script and
Open questions
Claude Opus 5.5, acting for Oscar Levin |
|
Thanks, Oscar. The rework answers round 1. A journal's style now reaches every conversion, a missing references file no longer stops a conversion, the Springer Nature class file arrives intact, and the new Python is about 45 lines. This reviews head What remains:
Round-1 findings: where they stand
1. BehaviorWhat was verifiedThe sample article was copied to scratch, so that no generated file lands in the repository. Its backmatter
1.1 A misspelled style name still ends in a traceback
1.2 Your question: an empty
|
| Commit | FALLBACK messages, conversion |
FALLBACK messages, -c references |
|---|---|---|
base 20d105454 |
stops with Cannot resolve URI |
0 |
d78fe0e99 (HEAD~14), the resolver |
0 (default formatting, silently) | 0 |
8618339e9 (HEAD~13) through 182a6108e (HEAD~1) |
2 | 1 |
4be592fe9 (HEAD) |
1 | 0 |
8618339e9 puts the missing-file test in a global variable. libxslt computes a global variable in every stylesheet that imports assembly, including the publisher-variable report. So every conversion printed the message twice. And -c references printed it during the very run that writes the file. 4be592fe9 repairs that. Both commits are in this PR, so folding the repair into 8618339e9 means the history never duplicates the message. 182a6108e (HEAD~1) finishes applying the switch that 8618339e9 introduced, so folding it in too would let the switch arrive whole.
3. Publication schema
290d4715e (HEAD~15) changes only the literate source. Regenerating it (litprog, then trang) adds 3 lines to publication-schema.rnc and 5 to publication-schema.rng. You left them for the maintainer's build, as with css/dist. But for the schema the convention is the reverse: the derived files go in the same commit as the source.
4. Guide
- Accuracy. Every claim now holds. The style applies in every output format, PreTeXt falls back and says so, the
-c referencesroute works, andreferences()refuses a style that puts citations in notes. The edited Guide validates against the dev schema with no messages, the same as its base. The journal table regenerates identically fromjournals-to-table.xsl. - Placement. The new
common-cslsubsection is three paragraphs of discussion in the reference chapter. The Guide's convention is a sentence or two there, plus a cross-reference, with the discussion in a conversational section that links back. That section already exists:topic-references, "(*) References (Lists of Works Cited)", an empty stub indoc/guide/author/topics.xml.
5. Smaller items
- Message wording. The new
FALLBACKmessage says "Citation Stylesheet Language" and "publisher file". The standard is the Citation Style Language, as the Guide and thejournals.xmlcomment say, and the Guide's term is "publication file". The mismatch warning, which predates the PR, has the same two slips. harvard1survives in comments inexamples/sample-article/publication.xml,publication-alegreya.xmlandpublication-print.xml. These include "Default is "harvard1"", which is wrong on two counts: the default is empty, and the style no longer exists.- Comment alignment. In each of five new comment blocks, one line's
-->is a column off from the rest:journals/journals.xmlline 24, one column rightxsl/latex/pretext-latex-texstyle.xslline 760, one column leftxsl/pretext-assembly.xslline 1173, one column leftxsl/pretext-assembly.xslline 1338, one column leftxsl/publisher-variables.xslline 287, one column left
6. Commit hygiene
- No commit has a body. Each commit keeps to one area. The Guide is in its own commit, and the generated table rides with its generator, which is right for a derived file.
- The topics are established:
Script:,Assembly:,Publisher variables:,Publication schema:,Texstyles:,Guide:, andJournals:(one earlier use). a412eaea3 (HEAD~17)names an attribute in its subject without the@. It should be"@compression".- The subjects run long. Five of the 19 exceed 80 characters, and
a715d1d8c (HEAD~12)is 103. On master, the median of the last 1,000 subjects is 58 characters, 90% are 71 or fewer, and none exceeds 100.
7. What is right
- The journal's style is resolved in
publisher-variables.xsl. There is one lookup, and the script, pretext-cli,references()and every conversion agree, with no parameter to pass. - Your first different choice, the style in
journals.xmlrather than the texstyle files, works well. It is a single XPath with noextendsto follow, the table reads the same element, and a style belongs to a journal, not to a LaTeX class. - Your second, the resolver in
common.xsltproc(), works too. It answers for exactly one file name, so any other missing file still fails as loudly as before. No caller can forget it, and it handles paths with spaces. - The mismatch check works for the first time.
- The texstyle cleanup is safe. Nothing in the code reads
bibliography-styleor the removedcmd/arg. - Everything round 1 listed as working well is kept.
Verification
- The sample article, copied to scratch with eight publication-file variants. Scenarios: journal only, before and after
-c references; journal plus APA against a stale file, then regenerated; uppercase code; a journal with no style;style=""; an unknown style; a dependent style; a path with a space, the file present and absent;citeproc-py-stylesabsent. LaTeX throughout, and HTML for the main path. - All 19 commits and the base: a LaTeX build with two publication files, then a build and
-c referenceswith an explicit style and no references file. - The mismatch case at the base
20d105454. place_latex_package_files()forspringer-natureandtheory-probab-math-statist, with the results checked byfile. The Springer URLs on both hosts, forv12,v13andv14.- The publication schema regenerated from the PR's source and compared. The Guide validated in its version form against
pretext-dev.rng, at the base and at the head. The journal table regenerated and compared. - The style lookup probed directly under citeproc-py 0.10.3 and 0.11.1.
Claude Opus 5.5, acting as a review assistant for Rob Beezer
|
I'll address the minor issues here as part of a merge |
|
Oscar, rather than ask for another round, I've made the round-2 changes myself on a copy of this branch, and it will go in from there. Your commits keep your name, dates and messages, apart from shorter subjects. Because it will be merged by cherry-picking the commits, GitHub will show this PR as closed rather than merged. The branch is rebuilt on current master, which is 20 commits newer than your base; nothing conflicted. It now has 18 commits: your 19, less two folded into earlier ones, plus one new commit. What changed
Left as they were: "publisher file" in the messages, since the existing messages use it throughout; "Citation Stylesheet Language" in a comment in Verification
Claude Opus 5.5, acting as a coding assistant for Rob Beezer |
|
Thanks, @oscarlevin. Merged with changes detailed above. Great to have this decided and resolved. |
Naming a journal in the publication file now selects that journal's Citation Style Language (CSL) style for references and citations, in every conversion. citeproc-py finds styles by name, through the
citeproc-py-stylespackage, instead of PreTeXt downloading them.journals/journals.xmlgives each journal's style ascitation-stylesheet-language/@style, the same element the publication file uses. The Guide's journal table has a new column for it.csl-style-filecomes from the journal. So the script, the CLI,references()and every conversion agree, with no stringparam. A style named in the publication file still wins.common.xsltproc()gives lxml a stand-in for the absent file, which is what thexsltprocexecutable effectively does.PTX:FALLBACK), and falls back to default formatting for citations and bibliography together.$csl-file, so the publisher's generated directory is respected.@compression="zip", not the URL's suffix; Springer Nature and TPMS are marked.citation-stylesheet-language. Only the source is changed; the derived.rnc/.rngare left for the maintainer build.pretext generate referencesor-c references), and theciteproc-py-stylesrequirement.Dependency: any style other than citeproc-py's one bundled style needs
pip install citeproc-py-styles, about 15 MB as a wheel and 63 MB installed.🤖 Generated with Claude Code