8
0

markdown2html.js 679 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module markdown-gfm/markdown2html
  7. */
  8. import marked from 'marked';
  9. /**
  10. * Parses markdown string to an HTML.
  11. *
  12. * @param {String} markdown
  13. * @returns {String}
  14. */
  15. export default function markdown2html( markdown ) {
  16. return marked.parse( markdown, {
  17. gfm: true,
  18. breaks: true,
  19. tables: true,
  20. xhtml: true,
  21. headerIds: false
  22. } );
  23. }
  24. export { marked };
  25. // Disable the autolink rule in the lexer (point it to a regex that always fail).
  26. marked.InlineLexer.rules.breaks.autolink = /^\b$/;
  27. marked.InlineLexer.rules.breaks.url = /^\b$/;