blockGamut.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /**
  2. * These are all the transformations that form block-level
  3. * tags like paragraphs, headers, and list items.
  4. */
  5. showdown.subParser('blockGamut', function (text, options, globals) {
  6. 'use strict';
  7. text = showdown.subParser('headers')(text, options, globals);
  8. // Do Horizontal Rules:
  9. var key = showdown.subParser('hashBlock')('<hr />', options, globals);
  10. text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, key);
  11. text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm, key);
  12. text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm, key);
  13. text = showdown.subParser('lists')(text, options, globals);
  14. text = showdown.subParser('codeBlocks')(text, options, globals);
  15. text = showdown.subParser('blockQuotes')(text, options, globals);
  16. // We already ran _HashHTMLBlocks() before, in Markdown(), but that
  17. // was to escape raw HTML in the original Markdown source. This time,
  18. // we're escaping the markup we've just created, so that we don't wrap
  19. // <p> tags around block-level tags.
  20. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  21. text = showdown.subParser('paragraphs')(text, options, globals);
  22. return text;
  23. });