markdown2html.js 529 B

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