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

📋 New lines in markdown lists are not written to typst #1777

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

rowanc1
Copy link
Member

@rowanc1 rowanc1 commented Jan 14, 2025

Fixes #1767

Copy link

changeset-bot bot commented Jan 14, 2025

🦋 Changeset detected

Latest commit: c81f7fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
myst-to-typst Patch
myst-cli Patch
mystmd Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rowanc1 rowanc1 merged commit 7f29af8 into main Jan 14, 2025
7 checks passed
@rowanc1 rowanc1 deleted the typst/new-lines branch January 14, 2025 03:33
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', ' '));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things like this would be better handled in myst AST --- the AST should be designed to correctly abstract over new line behavior (new paragraph or item where it should be, etc.) and remove all newlines otherwise (normalize the text), so that backends don't handle this at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could certainly be done much further upstream, e.g. at markdown parse. I don't think there are any consequences of that. Other backends (latex/word/jats) are not effected by these new lines. It is possible that a markdown round-trip would be.

We don't currently have a node for a stylistic-only-in-the-source-newline. Are you suggesting we just remove it all together?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a design decision to consider: to normalize the text to remove double spaces and new lines, since then in the backend you just pass the text to the renderer (typst in this case) and it will always work. You will not round-trip to the original markdown (I don't know if it is a problem). If you need to round-trip, then I think you need to keep the text exactly as-is (as you do now) and take care of it in the backend (or a separate pass), like you did above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typst: Lists across multiple lines are not rendered correctly in typst
2 participants