diff --git a/.changeset/rude-deers-lay.md b/.changeset/rude-deers-lay.md new file mode 100644 index 000000000..bfdd0e1ee --- /dev/null +++ b/.changeset/rude-deers-lay.md @@ -0,0 +1,5 @@ +--- +"myst-to-typst": patch +--- + +Typst program vs code. diff --git a/packages/myst-to-typst/src/container.ts b/packages/myst-to-typst/src/container.ts index 35d7a2aed..2ca9b7f31 100644 --- a/packages/myst-to-typst/src/container.ts +++ b/packages/myst-to-typst/src/container.ts @@ -41,6 +41,12 @@ function renderFigureChild(node: GenericNode, state: ITypstSerializer) { if (useBrackets) state.write('\n]'); } +function getDefaultCaptionSupplement(kind: CaptionKind | string) { + if (kind === 'code') kind = 'program'; + const domain = kind.includes(':') ? kind.split(':')[1] : kind; + return `${domain.slice(0, 1).toUpperCase()}${domain.slice(1)}`; +} + export const containerHandler: Handler = (node, state) => { if (state.data.isInTable) { fileError(state.file, 'Unable to render typst figure inside table', { @@ -117,8 +123,9 @@ export const containerHandler: Handler = (node, state) => { state.write('\n],'); } if (kind) { + const supplement = getDefaultCaptionSupplement(kind); state.write(`\n kind: "${kind}",`); - state.write(`\n supplement: [${kind[0].toUpperCase() + kind.substring(1)}],`); + state.write(`\n supplement: [${supplement}],`); } state.write('\n)'); if (label) state.write(` <${label}>`); diff --git a/packages/mystmd/tests/notebook-fig-embed/outputs/index.json b/packages/mystmd/tests/notebook-fig-embed/outputs/index.json index b0c28b989..efa957528 100644 --- a/packages/mystmd/tests/notebook-fig-embed/outputs/index.json +++ b/packages/mystmd/tests/notebook-fig-embed/outputs/index.json @@ -239,7 +239,7 @@ "kind": "Notebook", "slug": "interactive-notebooks", "location": "/interactive-notebooks.ipynb", - "title": "Interactive Notebooks with MyST" + "title": "Generate and Display Rich Outputs" } }, { @@ -273,7 +273,7 @@ "kind": "Notebook", "slug": "interactive-notebooks", "location": "/interactive-notebooks.ipynb", - "title": "Interactive Notebooks with MyST" + "title": "Generate and Display Rich Outputs" }, "children": [ {