Skip to content

Commit

Permalink
🏷️ Do not write implicit labels for markdown (#1722)
Browse files Browse the repository at this point in the history
Co-authored-by: Franklin Koch <franklinwkoch@gmail.com>
  • Loading branch information
rowanc1 and fwkoch authored Jan 6, 2025
1 parent 7d916fe commit 7d6dff2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/young-moles-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"myst-to-md": patch
---

do not write out implicit references for titles
2 changes: 1 addition & 1 deletion packages/myst-to-md/src/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function labelWrapper(handler: Handle) {
return (node: any, _: Parent, state: NestedState, info: Info): string => {
const ident = node.identifier ?? node.label;
const prefix = ident ? `(${ident})=\n` : '';
return `${prefix}${handler(node, _, state, info)}`;
return `${node.implicit ? '' : prefix}${handler(node, _, state, info)}`;
};
}

Expand Down
24 changes: 24 additions & 0 deletions packages/myst-to-md/tests/references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ cases:
(my-subheading)=
#### fourth
- title: implicitly labeled headings
mdast:
type: root
children:
- type: heading
depth: 1
label: first
identifier: first
implicit: true
children:
- type: text
value: first
- type: paragraph
children:
- type: text
value: 'Some % '
- type: emphasis
children:
- type: text
value: markdown
markdown: |-
# first
Some % *markdown*
- title: labeled quote
mdast:
type: root
Expand Down

0 comments on commit 7d6dff2

Please sign in to comment.