-
Notifications
You must be signed in to change notification settings - Fork 7
fix nested ordered lists with more than 10 items #104
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
fix nested ordered lists with more than 10 items #104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Structure looks good to me 👍🏾 Just one q: on the "5 spaces" fix
content = content | ||
.replace(/^\n+/, '') // remove leading newlines | ||
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one | ||
.replace(/\n/gm, '\n ') // indent with five spaces (five is important) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow why "5" spaces is important. Should we expound on that a bit more in the comment or fn description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, 5 spaces is a quick fix. And kinda brute forcing things
1. list item
2. list item 2
- sub item # this works, because the `-` is indented with four spaces, two more than the `2.`
...
10. list item 10
- sub item # this does not work, because the `-` is indented four spaces, only a single space over the `10.`. So we need 5 here instead`
So, forcing 5 spaces kinda fixes lists until 100 😬
But I probably can make an algorithm that will handle more gracefully the indentation width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And fixed~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, much more clear. And really nice one on the unit tests! 🥇
09554b6
to
4c6e5ba
Compare
4c6e5ba
to
828b25b
Compare
/** | ||
* This rule is used to convert ordered list items to markdown. | ||
* | ||
* This is based on he turndownService rule for listItems, but modified to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* This is based on he turndownService rule for listItems, but modified to | |
* This is based on the turndownService rule for listItems, but modified to |
content = content | ||
.replace(/^\n+/, '') // remove leading newlines | ||
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one | ||
.replace(/\n/gm, '\n ') // indent with five spaces (five is important) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, much more clear. And really nice one on the unit tests! 🥇
Ticket
https://community.openproject.org/projects/communicator-stream/work_packages/64414/activity
What are you trying to accomplish?
Fix an issue where nested ordered lists with more than 10 items would break when persisted.
Screenshots
What approach did you choose and why?
Based on turndown.js implementation of conversion of list items, make the indentation 5 spaces instead of 4. This allows the commonmarker gem used on OpenProject to properly parse large nested ordered lists.
Merge checklist