2015-01-16 05:21:33 +08:00
|
|
|
/**
|
|
|
|
* These are all the transformations that occur *within* block-level
|
|
|
|
* tags like paragraphs, headers, and list items.
|
|
|
|
*/
|
|
|
|
showdown.subParser('spanGamut', 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('spanGamut.before', text, options, globals);
|
2015-01-19 19:37:21 +08:00
|
|
|
text = showdown.subParser('codeSpans')(text, options, globals);
|
|
|
|
text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
|
|
|
|
text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
// Process anchor and image tags. Images must come first,
|
|
|
|
// because ![foo][f] looks like an anchor.
|
|
|
|
text = showdown.subParser('images')(text, options, globals);
|
|
|
|
text = showdown.subParser('anchors')(text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
// Make links out of things like `<http://example.com/>`
|
|
|
|
// Must come after _DoAnchors(), because you can use < and >
|
|
|
|
// delimiters in inline links like [this](<url>).
|
|
|
|
text = showdown.subParser('autoLinks')(text, options, globals);
|
|
|
|
text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
|
|
|
|
text = showdown.subParser('italicsAndBold')(text, options, globals);
|
2015-07-11 22:59:06 +08:00
|
|
|
text = showdown.subParser('strikethrough')(text, options, globals);
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2016-12-01 02:04:17 +08:00
|
|
|
// Do hard breaks
|
|
|
|
if (options.simpleLineBreaks) {
|
2016-12-21 07:57:10 +08:00
|
|
|
// GFM style hard breaks
|
2017-01-06 11:51:12 +08:00
|
|
|
text = text.replace(/\n/g, '<br />\n');
|
2016-12-01 02:04:17 +08:00
|
|
|
} else {
|
2016-12-21 07:57:10 +08:00
|
|
|
// Vanilla hard breaks
|
2017-01-06 11:51:12 +08:00
|
|
|
text = text.replace(/ +\n/g, '<br />\n');
|
2016-12-01 02:04:17 +08:00
|
|
|
}
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2016-03-21 01:08:44 +08:00
|
|
|
text = globals.converter._dispatch('spanGamut.after', text, options, globals);
|
2015-01-19 19:37:21 +08:00
|
|
|
return text;
|
2015-01-16 05:21:33 +08:00
|
|
|
});
|