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

Preserve list marker #348

Merged
merged 4 commits into from Mar 28, 2023
Merged

Preserve list marker #348

merged 4 commits into from Mar 28, 2023

Conversation

rpaul-stripe
Copy link
Contributor

This PR adds an attribute called marker to list nodes that preserves the marker symbol used for the list in the source document. For ordered lists, this is either ) or . and for unordered lists it is either - or *. The marker is already exposed by the tokenizer, so the parser just has to take this value and assign it to the attribute.

This PR also modifies the formatter so that it uses the marker provided by the source content when available instead of defaulting to a specific value. Previously, the formatter was programmed to always use 1. for ordered lists and - for unordered lists in order to enforce consistency.

The problem that has arisen with this behavior is that in cases where there are two separate lists that appear in immediate succession in a document, the marker needs to be different in order for the parser to correctly identify them as separate lists. This behavior is demonstrated by Example 301 in the CommonMark specification. Making the formatter respect the original marker used in the source content ensures that it will not erroneously combine separate lists that appear in sequence.

* qux


1) foo
Copy link
Contributor

Choose a reason for hiding this comment

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

Did not know 1) works in Markdown

@rpaul-stripe rpaul-stripe merged commit d46832b into main Mar 28, 2023
1 check passed
@rpaul-stripe rpaul-stripe deleted the preserve-list-marker branch March 28, 2023 18:13
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.

None yet

2 participants