marked.js 948 B

12345678910111213141516171819202122232425262728293031323334
  1. md.compilers.marked = (() => {
  2. var defaults = {
  3. breaks: false,
  4. gfm: true,
  5. pedantic: false,
  6. // plugins
  7. linkify: true,
  8. smartypants: false,
  9. }
  10. var description = {
  11. breaks: 'Enable GFM line breaks\n(requires the gfm option to be true)',
  12. gfm: 'Enable GFM\n(GitHub Flavored Markdown)',
  13. pedantic: 'Don\'t fix any of the original markdown\nbugs or poor behavior',
  14. // plugins
  15. linkify: 'Autoconvert URL-like text to links',
  16. smartypants: 'Use "smart" typographic punctuation\nfor things like quotes and dashes'
  17. }
  18. var ctor = ({storage: {state}}) => ({
  19. defaults,
  20. description,
  21. compile: (markdown) =>
  22. new marked.marked(
  23. state.marked,
  24. marked.headings(),
  25. state.marked.linkify ? marked.linkify() : () => {},
  26. state.marked.smartypants ? marked.smartypants() : () => {},
  27. ).parse(markdown)
  28. })
  29. return Object.assign(ctor, {defaults, description})
  30. })()