2015-01-16 05:21:33 +08:00
|
|
|
/**
|
|
|
|
* These are all the transformations that form block-level
|
|
|
|
* tags like paragraphs, headers, and list items.
|
|
|
|
*/
|
|
|
|
showdown.subParser('blockGamut', function (text, options, globals) {
|
2015-01-19 19:37:21 +08:00
|
|
|
'use strict';
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2016-03-21 01:08:44 +08:00
|
|
|
text = globals.converter._dispatch('blockGamut.before', text, options, globals);
|
2015-08-03 10:47:49 +08:00
|
|
|
|
2015-08-23 10:11:11 +08:00
|
|
|
// we parse blockquotes first so that we can have headings and hrs
|
|
|
|
// inside blockquotes
|
|
|
|
text = showdown.subParser('blockQuotes')(text, options, globals);
|
2015-01-19 19:37:21 +08:00
|
|
|
text = showdown.subParser('headers')(text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
// Do Horizontal Rules:
|
|
|
|
var key = showdown.subParser('hashBlock')('<hr />', options, globals);
|
2016-12-21 06:08:33 +08:00
|
|
|
text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
|
|
|
|
text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
|
|
|
|
text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
text = showdown.subParser('lists')(text, options, globals);
|
|
|
|
text = showdown.subParser('codeBlocks')(text, options, globals);
|
2015-08-27 10:41:59 +08:00
|
|
|
text = showdown.subParser('tables')(text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
// We already ran _HashHTMLBlocks() before, in Markdown(), but that
|
|
|
|
// was to escape raw HTML in the original Markdown source. This time,
|
|
|
|
// we're escaping the markup we've just created, so that we don't wrap
|
|
|
|
// <p> tags around block-level tags.
|
|
|
|
text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
|
|
|
|
text = showdown.subParser('paragraphs')(text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2016-03-21 01:08:44 +08:00
|
|
|
text = globals.converter._dispatch('blockGamut.after', text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-08-03 10:47:49 +08:00
|
|
|
return text;
|
2015-01-19 22:57:43 +08:00
|
|
|
});
|