Skip to content

Commit

Permalink
📋 New lines in markdown lists are not written to typst (#1777)
Browse files Browse the repository at this point in the history
Fixes #1767
  • Loading branch information
rowanc1 authored Jan 14, 2025
1 parent 884bd8d commit 7f29af8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-moles-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"myst-to-typst": patch
---

New lines in lists are not written to typst
4 changes: 3 additions & 1 deletion packages/myst-to-typst/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ function nextCharacterIsText(parent: GenericNode, node: GenericNode): boolean {

const handlers: Record<string, Handler> = {
text(node, state) {
state.text(node.value);
// We do not want markdown formatting to be carried over to typst
// As the meaning in lists, etc. is different
state.text(node.value.replaceAll('\n', ' '));
},
paragraph(node, state) {
const { identifier } = node;
Expand Down
28 changes: 26 additions & 2 deletions packages/myst-to-typst/tests/lists.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: myst-to-typst admonitions
title: myst-to-typst lists
cases:
- title: important admonition
- title: important list
mdast:
type: root
children:
Expand All @@ -25,3 +25,27 @@ cases:
- This is a list
+ My other, nested
+ bullet point list!
- title: List with new lines
mdast:
type: root
children:
- type: list
children:
- type: listItem
spread: true
children:
- type: text
value: |-
A list
with a new line
- type: listItem
spread: true
children:
- type: text
value: |
And math
- type: inlineMath
value: Ax=b
typst: |-
- A list with a new line
- And math $A x = b$

0 comments on commit 7f29af8

Please sign in to comment.