gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.

Home Page:http://kramdown.gettalong.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GFM mode does not support check boxes

binduwavell opened this issue Β· comments

-[ ] is unchecked
-[x] is checked


  • is unchecked
  • is checked

Pull requests are welcome if this feature should be implemented.

+1

Dear people from the future, if you want to +1, please use this feature from the future: https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments πŸ˜„

Can anyone provide the HTML output for this?

And use cases for this feature? I imagine this being nice in an issue or pull request but what should it do when used with kramdown on a plain website?

@gettalong

- [ ] first item
- [x] second item

would result in:

<ul class="contains-task-list">
<li class="task-list-item enabled"><input type="checkbox" class="task-list-item-checkbox"> first item</li>
<li class="task-list-item enabled"><input type="checkbox" class="task-list-item-checkbox" checked=""> second item</li>
</ul>

for logged in user with permissions and

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled=""> first item</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" checked="" disabled=""> second item</li>
</ul>

for logged out user or user without permission on GitHub.

Since kramdown does not know about any permissions I suggest dropping the enabled / disabled. So this would be a great output:

<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox"> first item</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" checked=""> second item</li>
</ul>

And use cases for this feature? I imagine this being nice in an issue or pull request but what should it do when used with kramdown on a plain website?

Please keep in mind that kramdown is not only used for plain websites. πŸ˜„ GitLab is actually considering using kramdown for all its Markdown rendering: https://gitlab.com/gitlab-org/gitlab-ce/issues/18552

one corner case:

- [ ] first item
- [x] second item

[ ]: http://space.example
[x]: http://x.example

renders like this on GitHub:

  • first item
  • x second item

Another request for Markdown rendering on GitLab was to support arbitrary whitespace within [ ]. See also https://gitlab.com/gitlab-org/gitlab-ce/issues/2949

@winniehell Thanks for your feedback!

Regarding the output: I would prefer the HTML output with the checkboxes disabled because this would work on any website, not just "checkbox aware" sites. This would have the advantage that clicking on the checkboxes wouldn't change the state of them and would lead to users expecting some change.

As for the corner case: This is no corner case in my opinion since the syntax description would say something like "If the list item marker is followed by an opening square bracket, a space or an uppercase/ lowercase ASCII 'x' character, and a closing square bracket, ...". So if the user doesn't use this, it won't work.

If we would handle your supposed corner case, what would you do about intermingled zero-width spaces? En or em spaces? I don't think such things can easily be handled in a general way, especially if you want to handle all possibly Unicode characters that look similar...

@winniehell The corner case I mentioned was for the arbitrary whitespace case.

As for the link case: I think that handling them as checkboxes would be the right call here, and not treating them as reference links.

@gettalong

I would prefer the HTML output with the checkboxes disable

Sure, that makes sense. πŸ‘

This is no corner case in my opinion

Maybe corner case wasn't the right term. πŸ˜‰ It's just a situation where it has to be decided whether task lists or links have precedence.

I think that handling them as checkboxes would be the right call here

I actually prefer that myself, too. πŸ˜„ I think that case is more likely.

what would you do about intermingled zero-width spaces?

I would have used [:blank:] to match the space: http://rubular.com/r/ADZYvFCrsM

Using a Unicode character property matcher like [:blank:] would potentially lead to very confusing results, see http://rubular.com/r/aqgr63mPSS where I amended your example with some more possible variations.

I would stay in the ASCII world and just the simple space and nothing else. In the issue you link the problem is not that the user doesn't want to use spaces but that he accidentally uses non-breaking spaces due to OS X keyboard layout. We can't really solve that problem...

would potentially lead to very confusing results

I am not sure that I agree the result is confusing but let's not discuss about spaces here. πŸ˜„

due to OS X keyboard layout. We can't really solve that problem...

That sounds desperate but I get your point. πŸ˜‰

Not really desperate since I'm not using OS X anymore πŸ˜‰

Closed because feature request issues are now tracked through a dedicated project - see https://github.com/gettalong/kramdown/projects/1