Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdownit options are created but not used #11

Closed
jaustin opened this issue Mar 9, 2019 · 4 comments
Closed

markdownit options are created but not used #11

jaustin opened this issue Mar 9, 2019 · 4 comments

Comments

@jaustin
Copy link

jaustin commented Mar 9, 2019

/* 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)

@danurbanowicz
Copy link
Owner

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

@danurbanowicz danurbanowicz added the bug Something isn't working label Mar 11, 2019
@jaustin
Copy link
Author

jaustin commented Mar 11, 2019

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?

@danurbanowicz
Copy link
Owner

danurbanowicz commented Mar 12, 2019

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.

@danurbanowicz danurbanowicz removed the bug Something isn't working label Mar 14, 2019
@danurbanowicz
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants