danurbanowicz / eleventy-netlify-boilerplate

A template for building a blog with the Eleventy static site generator and Decap CMS

Home Page:https://eleventy-netlify-boilerplate.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

markdownit options are created but not used

jaustin opened this issue · comments

/* Markdown Plugins */
let markdownIt = require("markdown-it");
let options = {
html: true,
breaks: true,
linkify: true
};

I ended up getting a bit confused by the presence of this block given the removal of the call to
eleventyConfig.setLibrary("md", markdownIt(options)); (removed in 42084ba, perhaps as collateral when removing markdownit-anchor?)

I think it'd be clearer either to make the call to set the options, or remove the block containing the options. In my case this was confusing because at first pass I was expecting breaks to be enabled, but they weren't as the default config was being used, which has breaks: false

(If removing the config, I think the block below can go too)

Thanks for spotting this @jaustin !

The call to markdownIt(options) was removed by mistake resulting in the default markdown-it options being used, my bad. Breaks in markdown should be working again now.

Fixed by 8d92b70

Thanks for the quick answer, that fix looks sane, though I think the only downside is that for me with this setup the CMS preview will now show different behaviour to the widget itself. Actually I can't really get away from this I don't think?:

  • With breaks in markdown-it: Rendered output matches Slate widget contents itself, but not CMS preview
  • Without breaks in markdown-it: Rendered output matches preview in CMS but not in Slate widget

I guess one way to resolve that would be to render the body of the preview with markdown-it directly?

The previews are rendered in React using the Netlify CMS window.CMS object, probably using (I haven't checked) the react-markdown plugin which requires 2 or more spaces after each line followed by a newline character to generate a <br> tag, which apparently follows the Markdown spec. I have tested this and it works.

Closing this for now, but let me know if you feel this still needs looking at and I will re-open. Thanks.