Open
Conversation
…y ref parsing serializeToJATS() now returns the built Document instead of an already-serialized string, letting each consumer choose its own serialization strategy. Callers under Node (real DOM) can use the real w3c-xmlserializer; manuscripts-cf-worker's linkedom-based DOM can just call Document#toString(). This removes the need for cf-worker's patched w3c-xmlserializer, whose spec-correct namespace resolution never worked against linkedom's DOM model. w3c-xmlserializer moves from a runtime dependency to a devDependency, used only by this package's own test suite (which runs under jsdom) to stringify the returned Document for snapshot/content assertions. Also replaces the <template> wrapper tag used when parsing each citeproc-generated bibliography entry with <wrapper>: <template> is a recognized HTML special element, and linkedom applies its special content-fragment handling to it even during XML parsing, which breaks extracting the nested <ref> back out. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The public API now returns a Document from serializeToJATS(), which is a breaking change and currently leaves the method naming/consumer-facing documentation inconsistent, increasing the risk of downstream misuse.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adjusts the JATS export surface to return a DOM Document from JATSExporter.serializeToJATS() (instead of an XML string), and updates bibliography parsing to avoid linkedom’s special <template> handling so <ref> extraction works reliably across runtimes.
Changes:
- Change
serializeToJATS()to return the builtDocumentrather than a serialized XML string. - Update citeproc bibliography entry parsing wrapper from
<template>to<wrapper>to restore<ref>extraction under linkedom. - Move
w3c-xmlserializerusage into tests (and todevDependencies) for snapshot/DTD assertions.
File summaries
| File | Description |
|---|---|
| src/jats/exporter/jats-exporter.ts | Return a DOM Document from serializeToJATS() and adjust bibliography <ref> parsing wrapper element. |
| src/jats/tests/jats-roundtrip.test.ts | Serialize returned Document with w3c-xmlserializer for roundtrip snapshot + DTD validation. |
| src/jats/tests/jats-exporter.test.ts | Serialize returned Document with w3c-xmlserializer for snapshots and DTD assertions. |
| package.json | Move w3c-xmlserializer from dependencies to devDependencies. |
| pnpm-lock.yaml | Lockfile updates reflecting dependency move and related resolution metadata changes. |
Review details
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
- Files reviewed: 4/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
165
to
+168
| public serializeToJATS = async ( | ||
| manuscriptNode: ActualManuscriptNode, | ||
| options: ExportOptions | ||
| ): Promise<string> => { | ||
| ): Promise<Document> => { |
permittedActions is now a single flat string[] with no distinction between package-level enums — the merged set of actions lives in article-editor's local capabilities.tsx instead (alongside body-editor's former Actions enum, removed the same way). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Project had zero real consumers anywhere outside manuscripts-api
(explicitly out of scope). UserProfile's only real internal usage was a
string ID prefix, not the type itself; its actual consumers were all in
host apps, which now use a plain User shape ({id, displayName, firstName?,
lastName?}) sourced entirely from props rather than fetched — connectID
is dropped since nothing ever read it.
manuscripts-api has live imports of both Project and UserProfile
(ProjectController.ts, UserService.ts, etc.) and will need its own
follow-up migration once it moves off these.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
serializeToJATS()now returns the builtDocumentinstead of a serialized string, so each consumer can choose its own serialization strategy (realw3c-xmlserializerunder Node/jsdom, orDocument#toString()under linkedom-based runtimes like Cloudflare Workers).w3c-xmlserializermoves from a runtimedependencyto adevDependency— it's now only used by this package's own test suite to stringify the returnedDocumentfor assertions.<template>wrapper tag used when parsing each citeproc-generated bibliography entry is replaced with<wrapper>, since linkedom applies HTML<template>'s special content-fragment handling to it even during XML parsing, which broke extracting the nested<ref>back out.Test plan
pnpm typecheckpassespnpm test— 74/74 passw3c-xmlserializer🤖 Generated with Claude Code