Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏷️ Do not label implicit heading nodes #1755

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dull-ravens-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"myst-to-typst": patch
---

Do not label implicit heading nodes in typst
5 changes: 3 additions & 2 deletions packages/myst-to-typst/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ const handlers: Record<string, Handler> = {
state.renderChildren(node, 2, { after });
},
heading(node, state) {
const { depth, identifier, enumerated } = node;
const { depth, identifier, enumerated, implicit } = node;
state.write(`${Array(depth).fill('=').join('')} `);
state.renderChildren(node);
if (enumerated !== false && identifier) {
if (enumerated !== false && identifier && !implicit) {
// Implicit labels can have duplicates and stop typst from compiling
state.write(` <${identifier}>`);
}
state.write('\n\n');
Expand Down
4 changes: 3 additions & 1 deletion packages/mystmd/tests/include-recursive/three.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(pg-3)=

# Page three

This page does not include any other pages.
This page does not include any other pages.
6 changes: 3 additions & 3 deletions packages/mystmd/tests/math-macros/outputs/index.typ
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
#let six = $d = d$
#let seven = $d = d = d$

= No plugins <no-plugins>
= No plugins

$ a^2 + b^2 = c^2 $
= Simple plugin <simple-plugin>
= Simple plugin

Project frontmatter should give us `d`

$ d = three $
Page should override and we should see `x`

$ x = one $
= Macros should recurse <macros-should-recurse>
= Macros should recurse

Page frontmatter should fill in this project macro

Expand Down
8 changes: 4 additions & 4 deletions packages/mystmd/tests/outputs/include-circular.typ
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
This page includes content from page two:

= Page two <page-two>
= Page two

This page includes content from page three:

= Page three <page-three>
= Page three

This page includes content from page one:

and content from page three:

= Page three <page-three>
= Page three

This page includes content from page one:

and page four:

= Page four <page-four>
= Page four

This page includes content from itself:
6 changes: 3 additions & 3 deletions packages/mystmd/tests/outputs/include-recursive.typ
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
This page includes content from page two:

= Page two <page-two>
= Page two

This page includes content from page three:

= Page three <page-three>
= Page three <pg-3>

This page does not include any other pages.

and content from page three:

= Page three <page-three>
= Page three <pg-3>

This page does not include any other pages.
Loading