Marked: GFM: my task lists not rendered

Created on 21 Nov 2015  Â·  5Comments  Â·  Source: markedjs/marked

my test code:

### Solar System Exploration, 1950s – 1960s

- [ ] Mercury
- [x] Venus
- [x] Earth (Orbit/Moon)
- [x] Mars
- [ ] Jupiter
- [ ] Saturn
- [ ] Uranus
- [ ] Neptune
- [ ] Comet Haley

results:

Solar System Exploration, 1950s – 1960s

- [ ] Mercury
- [x] Venus
- [x] Earth (Orbit/Moon)
- [x] Mars
- [ ] Jupiter
- [ ] Saturn
- [ ] Uranus
- [ ] Neptune
- [ ] Comet Haley

my config:

marked.setOptions({
    gfm: true,
    tables: true,
    highlight: function (code, lang) {
        return hljs.highlightAuto(code, [lang]).value;
    }
});

Most helpful comment

+1 to add this feature by default

All 5 comments

I think task lists are not considered part of GFM, but as an additional feature of GitHub, just like auto-linking of commits/users/issues references.

I was looking for this today as well. Would love to see it added here!

I found this #107 , It works

var renderer = new marked.Renderer();
renderer.listitem = function(text) {
if (/^\s*\[[x ]\]\s*/.test(text)) {
text = text
  .replace(/^\s*\[ \]\s*/, '<i class="empty checkbox icon"></i> ')
  .replace(/^\s*\[x\]\s*/, '<i class="checked checkbox icon"></i> ');
    return '<li style="list-style: none">' + text + '</li>';
  } else {
    return '<li>' + text + '</li>';
  }
};

+1 to add this feature by default

982

Was this page helpful?
0 / 5 - 0 ratings

Related issues

james4388 picture james4388  Â·  3Comments

gclove picture gclove  Â·  4Comments

mjbvz picture mjbvz  Â·  4Comments

learykara picture learykara  Â·  3Comments

amejiarosario picture amejiarosario  Â·  3Comments