marked.js 974 B

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