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

Correctly handle numbers for ordered list items #372

Merged
merged 1 commit into from May 9, 2023

Conversation

rpaul-stripe
Copy link
Contributor

@rpaul-stripe rpaul-stripe commented May 9, 2023

This PR addresses issue #371, ensuring that ordered lists are rendered with a start attribute that reflects the number of the first item in the list. This is consistent with the behavior described in the CommonMark specification. The PR also introduces a new value attribute on list item AST nodes that captures the list number used for each ordered list item.

  • Parser modifications
    • Modifies the parser so that the leading symbol for a list item is assigned to the value property on the AST node
    • Adds a parser Jasmine test case to ensure that ordered and unordered lists have the correct values for the value attribute
  • Schema modifications
    • Modifies the schema to add the new value attribute to the list item node
    • Modifies the list node transform function so that when the list is ordered it walks the children, obtains the value attribute of the first child, and uses that as the start value passed into the render tree
    • Modifies a marktest case with ordered list items in order to reflect the presence of the start attribute in the render tree
  • Formatter modifications
    • Modifies the formatter so that it computes the list prefix for each individual item, using the value attribute for ordered list items and falling back to "1" when it is not present
    • Modifies the formatter test cases so that they verify that the ordered list numbers are preserved

Closes #371

Copy link
Contributor

@mfix-stripe mfix-stripe left a comment

Choose a reason for hiding this comment

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

Thanks for handling @rpaul-stripe!

@rpaul-stripe rpaul-stripe merged commit f419064 into main May 9, 2023
2 checks passed
@rpaul-stripe rpaul-stripe deleted the preserve-list-number branch May 9, 2023 17:46
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.

Start numbers of ordered lists are ignored
2 participants