From 4f630bd81e8cbd647486b0d571fe61684bbe4afc Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Mon, 30 Jun 2025 17:49:08 -0700 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=81=20For=20JATS=20output,=20use?= =?UTF-8?q?=20=20to=20wrap=20parenthetical=20citation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #2136 --- .../myst-to-jats/src/transforms/citations.ts | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/myst-to-jats/src/transforms/citations.ts b/packages/myst-to-jats/src/transforms/citations.ts index 256b4eb19..f3928f57b 100644 --- a/packages/myst-to-jats/src/transforms/citations.ts +++ b/packages/myst-to-jats/src/transforms/citations.ts @@ -4,7 +4,7 @@ import { selectAll } from 'unist-util-select'; import type { GenericNode, GenericParent } from 'myst-common'; /** - * Add parentheses and separator text to citeGroup nodes as children + * Add tag and separator text to citeGroup with nodes as children * * This allows us to simply render children and get all the correct formatting. */ @@ -21,17 +21,13 @@ export function citeGroupTransform(mdast: GenericParent) { node.children.forEach((child) => { child.kind = kind; }); - const newChildren: GenericNode[] = []; - if (kind === 'parenthetical') { - newChildren.push({ - type: 'text', - value: '(', - }); - } - newChildren.push(node.children[0]); + const wrapper: GenericNode = { type: 'superscript', children: [] }; + wrapper.children = []; + + wrapper.children.push(node.children[0]); const sep = kind === 'parenthetical' ? ';' : ','; node.children.slice(1).forEach((child) => { - newChildren.push( + wrapper.children!.push( { type: 'text', value: `${sep} `, @@ -39,13 +35,7 @@ export function citeGroupTransform(mdast: GenericParent) { child, ); }); - if (kind === 'parenthetical') { - newChildren.push({ - type: 'text', - value: ')', - }); - } - node.children = newChildren as any[]; + node.children = kind == 'parenthetical' ? ([wrapper] as any[]) : wrapper.children; }); } From e1cca3ab036fa6b0a753db2424d0a329e547ac59 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Mon, 30 Jun 2025 17:53:14 -0700 Subject: [PATCH 2/2] Add changeset --- .changeset/young-eggs-work.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/young-eggs-work.md diff --git a/.changeset/young-eggs-work.md b/.changeset/young-eggs-work.md new file mode 100644 index 000000000..3dbf9b9fa --- /dev/null +++ b/.changeset/young-eggs-work.md @@ -0,0 +1,5 @@ +--- +'myst-to-jats': minor +--- + +Wrap parenthetical citations in tag to group citations