commonmark.js 736 B

1234567891011121314151617181920212223242526272829303132
  1. md.compilers.commonmark = (() => {
  2. var defaults = {
  3. safe: false,
  4. smart: false,
  5. sourcepos: false
  6. }
  7. var description = {
  8. safe: 'Raw HTML will not be rendered',
  9. smart: [
  10. 'Straight quotes will be made curly',
  11. '-- will be changed to an en dash',
  12. '--- will be changed to an em dash',
  13. 'and ... will be changed to ellipses'
  14. ].join('\n'),
  15. sourcepos: ''
  16. }
  17. var ctor = ({storage: {state}}) => ({
  18. defaults,
  19. description,
  20. compile: (markdown) => ((
  21. reader = new commonmark.Parser(),
  22. writer = new commonmark.HtmlRenderer(state.commonmark)
  23. ) =>
  24. writer.render(reader.parse(markdown))
  25. )()
  26. })
  27. return Object.assign(ctor, {defaults, description})
  28. })()