-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
GFM compliance for tasks lists #1250
Conversation
lib/marked.js
Outdated
+ (checked ? 'checked="" ' : '') | ||
+ 'disabled="" type="checkbox"' | ||
+ (this.options.xhtml ? ' /' : '') | ||
+ '>'; |
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.
from the specs it looks like there should be a space after >
test/specs/gfm/gfm-spec.js
Outdated
@@ -15,7 +15,8 @@ Messenger.prototype.test = function(spec, section, ignore) { | |||
var shouldFail = ~ignore.indexOf(spec.example); | |||
it('should ' + (shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, function() { | |||
var expected = spec.html; | |||
var actual = marked(spec.markdown, { headerIds: false, xhtml: true }); | |||
var usexhtml = typeof spec.xhtml === 'boolean' ? spec.xhtml : true; | |||
var actual = marked(spec.markdown, { headerIds: false, xhtml: usexhtml }); |
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.
It looks like just setting the xhtml
option to false for all gfm the tests works
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 think CommonMark uses XHTML maybe the GFM extensions don't need XHTML. (I do think there's something to be said for the attempted solution - putting the options in the JSON - but not sure we've hit a point of actually needing it.)
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'll just turn off xhtml altogether for gfm tests, and remove this spec property.
lib/marked.js
Outdated
@@ -363,10 +365,20 @@ Lexer.prototype.token = function(src, top) { | |||
if (!loose) loose = next; | |||
} | |||
|
|||
// Check for task list items | |||
istask = /^\[[ xX]\]/.test(item); |
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.
a space seems to be required after [ ]
other wise it is rendered like text
with space:
- test
without space:
- [x]test
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'll add this space to the pattern, along with the corresponding change below.
lib/marked.js
Outdated
ischecked = undefined; | ||
if (istask) { | ||
ischecked = item[1] !== ' '; | ||
item = item.replace(/^\[[ xX]\] */, ''); |
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.
- /^\[[ xX]\] */
+ /^\[[ xX]\] +/
since at least one space is required
I've addressed a few things.
There are no other outstanding concerns to my knowledge. |
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.
Tom, you are on a roll 💯
I'm on vacation this week, and I resolved not to work on work, but I have to work on something! |
@tomtheisen This is huge! 🏋️ |
* marked 0.4.0 has Compliant with GFM task list * markedjs/marked#1250 * fix: Remove extra inner linebreak from code blocks
GFM compliance for tasks lists
Marked version: 0.3.19
Markdown flavor: GitHub Flavored Markdown
Fixes #107
Fixes #419
Fixes #170
Fixes #689
Fixes #587
Description
This adds task list items support as specified in GFM. These are the checkboxes you can make in bulleted lists.
I did do some funny stuff in the gfm test runner. In particular all the other gfm tests use the xhtml rendering option. But for some reason, (probably not a good one) the checkbox rendering in the gfm spec is not xhtml. So, I added a an
xhtml
attribute to the test spec json for those tests. It seems pretty janky. Maybe someone can think of a better way of handling it.Contributor
Committer
In most cases, this should be a different person than the contributor.