leeoniya / reMarked.js

client-side HTML > markdown
http://leeoniya.github.io/reMarked.js/
400 stars 97 forks source link

demo outputs code blocks fenced with 'true' not '```' #47

Open 100ideas opened 7 years ago

100ideas commented 7 years ago

BoostIO/Boostnote/issues/923

screen shot 2017-09-30 at 2 40 21 pm

Safari Version 11.0 (13604.1.38.1.6)

reproduce / fix:

// try it by pasting into the console at reMarked demo site [1]

// code blocks will be delimited with the string 'true' - default behavior in frontend
var reMarker = new reMarked({gfm_code: true});

// this is what we want
var reMarker = new reMarked({gfm_code: "```"});
reMarker.render(document.getElementById('html-inp').value)

[1] http://leeoniya.github.io/reMarked.js/

leeoniya commented 7 years ago

heh, woops.

i think the error is not in the example, but in the lib.

the idea is to provide string options when there are multiple output types for the same thing (emphasis, lists, etc). gfm code block are unambiguously always surrounded by backticks [1], so the option does in fact need to be a boolean toggle.

on a separate note, i plan to update the lib soon so it plays nice with strict mode, too. right now it relies on https://github.com/ded/klass which violates strict, but that can now be dropped with es6's class and compiling down to es5 via https://buble.surge.sh/

might even break out all the node types into es6 modules and build with Rollup.

have any interest in contributing these updates? they should be mostly mechanical.

[1] https://help.github.com/articles/creating-and-highlighting-code-blocks/

100ideas commented 7 years ago

I would be happy to help out, maybe you could create an issue and assign me to it?

Also, I think this error actually is caused by demo.js#L49:gfm_code is set to true not ```:

var options = {
  link_list:  false,    // render links as references, create link list as appendix
  h1_setext:  true,     // underline h1 headers
  h2_setext:  true,     // underline h2 headers
  h_atx_suf:  false,    // header suffixes (###)
  gfm_code:   true,     // gfm code blocks (```)
  li_bullet:  "*",      // list item bullet style
  hr_char:    "-",      // hr style
  ...

So ideally we would refactor the code so that gfm_code option is a boolean?

leeoniya commented 7 years ago

i have to stop replying to github issue on my phone.

you're right. i just forgot to update the gh-pages branch with the latest commit that added configurable gfm_code wrappers, since ~~~ is valid, too. i'm going to hold off on that demo update in favor of revamping the codebase to ES6 classes, adding in Rollup/Buble and making unit tests for each feature to run through QUnit rather than the current esoteric process which requires jquery, php, etc.

46 already exists for the ES6 class conversion task.