-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Start ordered lists using the initial numbers from markdown lists #1144
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
Conversation
Adds tests for list creation and continuation when starting with a number other than 1. Emits 'start' attribute only when necessary; simple cases behave as always.
@paulroub: Thanks again for this contribution! We've started moving toward using Jasmine for our test harness. We are also looking to stick as close we can to objective examples from the specifications themselves. There are two entries in the CommonMark spec that seem be related to this issue. Would you be willing and able to create tests for these two examples using the proposed solution? http://spec.commonmark.org/0.28/#example-230 - starting at 0 results in a forced starting number. http://spec.commonmark.org/0.28/#example-234 - start at 10 and have a code block within a list item. If you can add a test in |
ps. Please keep the tests you have (or copy and paste from the spec to update html and MD files). |
Fixed a bug in the initial implementation of ordered-list initialization. Add a simpler unit test around starting-from-zero.
@paulroub: This looks good to me. Having said that, I would like to get a second and possibly a third pair of eyes. Thank you so much! |
lib/marked.js
Outdated
return '<' + type + '>\n' + body + '</' + type + '>\n'; | ||
Renderer.prototype.list = function(body, ordered, start) { | ||
var type = ordered ? 'ol' : 'ul', | ||
startatt = (ordered && +start !== 1) ? (' start="' + start + '"') : ''; |
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.
Why are you casting +start
here? Isn't it already a number from +bull
above?
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.
LGTM! Merging. Thanks for the reviews everyone and the well-formed submission.
Start ordered lists using the initial numbers from markdown lists
Adds tests for list creation and continuation when starting with a
number other than 1.
Emits 'start' attribute only when necessary; simple cases behave as
always.
Marked version: 0.3.17
Markdown flavor: CommonMark
Description
Contributor
Committer
In most cases, this should be a different person than the contributor.