mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
|
/**
|
||
|
* Created by Estevao on 11-01-2015.
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* These are all the transformations that form block-level
|
||
|
* tags like paragraphs, headers, and list items.
|
||
|
*/
|
||
|
showdown.subParser('blockGamut', function (text, options, globals) {
|
||
|
'use strict';
|
||
|
|
||
|
text = showdown.subParser('headers')(text, options, globals);
|
||
|
|
||
|
// Do Horizontal Rules:
|
||
|
var key = showdown.subParser('hashBlock')('<hr />', options, globals);
|
||
|
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);
|
||
|
|
||
|
text = showdown.subParser('lists')(text, options, globals);
|
||
|
text = showdown.subParser('codeBlocks')(text, options, globals);
|
||
|
text = showdown.subParser('blockQuotes')(text, options, globals);
|
||
|
|
||
|
// 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);
|
||
|
|
||
|
return text;
|
||
|
});
|
||
|
|