gnab / remark

A simple, in-browser, markdown-driven slideshow tool.
http://remarkjs.com
MIT License
12.68k stars 856 forks source link

GFM tasklist support #614

Open strawp opened 4 years ago

strawp commented 4 years ago

I understand that remark uses code from markedjs, however markedjs appears to support tasklist syntax (example) and in remark this doesn't work.

Can this be supported?

dvberkel commented 4 years ago

Hi @strawp We do use markedjs as our markdown parser, albeit an old version. This project has a long history and for a long time it was hard to find time to maintain it.

Recently, more people joined the maintenance effort, so expect to see some movements again.

Having said that, there is some discussion to change markdown parser. I am not sure which direction that discussion will go, but we will consider supporting task lists.

strawp commented 4 years ago

Cool, thanks!

strawp commented 3 years ago

I had a little look at this as it looked like just dropping the newest version of markedjs might have worked, but it appears it's not as simple as that as 7 tests then fail during make. Is remark hooking into markedjs in a way that it's not simply passing markdown into it and getting HTML out?

strawp commented 3 years ago

Another dig into the code...

I can pass one test with referenced links by changing converted.js so that instead of patching the links object in tokens returned by marked's lexer, I just construct the links in markdown based on the links object passed to convertMarkdown() so that it does this instead:

  if( links ){
    var linksmd = ''; 
    for( var id in links ){
        linksmd += '['+id+']: ';
        if( 'href' in links[id] ){
            linksmd += links[id].href;
        }   
        if( 'title' in links[id] ){
            linksmd += ' "' + links[id].title + '"';
        }   
        linksmd += "\n";
    }   
    markdown += "\n\n" + linksmd;
  }

  var tokens = marked.Lexer.lex(markdown.replace(/^\s+/, ''));
  html = marked.Parser.parse(tokens);

All the other test failures are in SlideView code highlighting. I haven't looked at that code yet

strawp commented 3 years ago

I've now got this working. Targeted marked 1.2.0 and highlight.js 10.2.1. Had to turn off pedantic in the marked options but that doesn't seem to have had any ill effect. Working task lists though!