diff --git a/.changeset/thirty-islands-pump.md b/.changeset/thirty-islands-pump.md new file mode 100644 index 000000000..3ca1b0ec4 --- /dev/null +++ b/.changeset/thirty-islands-pump.md @@ -0,0 +1,5 @@ +--- +'myst-to-typst': patch +--- + +Fix inlinecode when there are children diff --git a/packages/myst-to-typst/src/index.ts b/packages/myst-to-typst/src/index.ts index e402d3d0b..389802042 100644 --- a/packages/myst-to-typst/src/index.ts +++ b/packages/myst-to-typst/src/index.ts @@ -182,14 +182,16 @@ const handlers: Record = { }, inlineCode(node, state) { let ticks = '`'; + // inlineCode can sometimes have children (e.g. from latex) + const value = toText(node); // Double ticks create empty inline code; we never want that for start/end - while (ticks === '``' || node.value.includes(ticks)) { + while (ticks === '``' || value.includes(ticks)) { ticks += '`'; } state.write(ticks); - if (node.value.startsWith('`')) state.write(' '); - state.write(node.value); - if (node.value.endsWith('`')) state.write(' '); + if (value.startsWith('`')) state.write(' '); + state.write(value); + if (value.endsWith('`')) state.write(' '); state.write(ticks); }, subscript(node, state) { @@ -206,8 +208,6 @@ const handlers: Record = { state.ensureNewLine(); }, abbreviation(node, state) { - // TODO: \newacronym{gcd}{GCD}{Greatest Common Divisor} - // https://www.overleaf.com/learn/latex/glossaries state.renderChildren(node, true); }, link: linkHandler,