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

Start ordered lists using the initial numbers from markdown lists #1144

Merged
merged 4 commits into from Mar 21, 2018

Conversation

paulroub
Copy link
Contributor

@paulroub paulroub commented Mar 15, 2018

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

  • Test(s) exist to ensure functionality and minimize regresstion (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

  • Draft GitHub release notes have been updated.
  • CI is green (no forced merge required).
  • Merge PR

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.
@joshbruce
Copy link
Member

@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 /test/integration/marked-spec.js file it will help us determine where marked is objectively failing against the spec instead of any one of our interpretations of it. Tagging @UziTech to help with any test harness questions.

@joshbruce
Copy link
Member

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.
@joshbruce
Copy link
Member

@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 + '"') : '';
Copy link
Member

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?

@styfle styfle requested a review from joshbruce March 21, 2018 17:08
Copy link
Member

@joshbruce joshbruce left a 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.

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.

Ordered lists always start with 1, regardless of starting number in markdown
4 participants