-
Notifications
You must be signed in to change notification settings - Fork 7
Replaced marked with markdown-it #19
base: master
Are you sure you want to change the base?
Conversation
@@ -64,36 +77,47 @@ toHtml attrs string = | |||
[dash]: http://en.wikipedia.org/wiki/Dash | |||
-} | |||
type alias Options = | |||
{ githubFlavored : Maybe { tables : Bool, breaks : Bool } | |||
{ full : Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full is a terrible name for an option. I have no idea what this does
I've left some comments. Generally, it's best practice to not just copy whatever JS libaries do. They use bad names and bad data structures. Think about the perspective of the Elm user. Names should be clear, and sensible. You can convert a option record to a record that matches the markdown library after the Elm programmer has touched it. Make life easier for the Elm programmer, not for the JS lib. |
"full" enables all of what markdown-it has to offer. I didn't stay with "githubFlavored" because markdown-it offers more than that I think. But "githubFlavored" would still probably be a better/more accurate name than "full". For the quotes, markdown-it allows you to change the "smart" quotes that it adds if you've enabled that option. To change them, you can use a string 4 characters wide, e.g. |
naming is hard! 👍 much better names for the quote options |
Just updated the PR with some better names. Any other issues? |
marked
hasn't been updated in nearly a year, is looking unmaintained, and was just found to be vulnerable to XSS attacks.This PR replaces
marked
withmarkdown-it
, a newer, actively maintained Markdown parser based onremarkable
.markdown-it
conforms to the CommonMark spec, but also supports Github flavored Markdown stuff like tables and code fencing (disabled by default). It's also faster thanmarked
according to their benchmarks.The changes in this PR are mainly replacing the
marked
library withmarkdown-it
, and tweaking theOptions
for this new parser. Here are the options markdown-it supports natively for reference.One non-trivial change (from a users perspective) is enabling input sanitization by default (which is now behind the
html = False
flag). It's very easy to forget about enabling sanitization with custom options, and I think having it on by default is worth avoiding the risk of accidentally releasing XSS exploitable code into production. I'd like to hear what you all think about this.Feedback welcome. I'm happy to make nitpick/stylistic changes as well.
Should fix #6, #9, #16, and #17.