2015-01-16 05:21:33 +08:00
|
|
|
showdown.subParser('blockQuotes', function (text, options, globals) {
|
2015-01-19 19:37:21 +08:00
|
|
|
'use strict';
|
|
|
|
|
2015-08-03 10:47:49 +08:00
|
|
|
text = globals.converter._dispatch('blockQuotes.before', text, options);
|
2015-01-19 19:37:21 +08:00
|
|
|
/*
|
|
|
|
text = text.replace(/
|
|
|
|
( // Wrap whole match in $1
|
|
|
|
(
|
|
|
|
^[ \t]*>[ \t]? // '>' at the start of a line
|
|
|
|
.+\n // rest of the first line
|
|
|
|
(.+\n)* // subsequent consecutive lines
|
|
|
|
\n* // blanks
|
|
|
|
)+
|
|
|
|
)
|
|
|
|
/gm, function(){...});
|
|
|
|
*/
|
|
|
|
|
2015-08-23 10:11:11 +08:00
|
|
|
text = text.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) {
|
2015-01-19 19:37:21 +08:00
|
|
|
var bq = m1;
|
|
|
|
|
|
|
|
// attacklab: hack around Konqueror 3.5.4 bug:
|
|
|
|
// "----------bug".replace(/^-/g,"") == "bug"
|
|
|
|
bq = bq.replace(/^[ \t]*>[ \t]?/gm, '~0'); // trim one level of quoting
|
|
|
|
|
|
|
|
// attacklab: clean up hack
|
|
|
|
bq = bq.replace(/~0/g, '');
|
|
|
|
|
|
|
|
bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
|
2015-08-26 04:10:49 +08:00
|
|
|
bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
|
2015-01-19 19:37:21 +08:00
|
|
|
bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
|
|
|
|
|
|
|
|
bq = bq.replace(/(^|\n)/g, '$1 ');
|
|
|
|
// These leading spaces screw with <pre> content, so we need to fix that:
|
|
|
|
bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
|
|
|
|
var pre = m1;
|
|
|
|
// attacklab: hack around Konqueror 3.5.4 bug:
|
|
|
|
pre = pre.replace(/^ /mg, '~0');
|
|
|
|
pre = pre.replace(/~0/g, '');
|
|
|
|
return pre;
|
|
|
|
});
|
|
|
|
|
|
|
|
return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
|
|
|
|
});
|
2015-08-03 10:47:49 +08:00
|
|
|
|
|
|
|
text = globals.converter._dispatch('blockQuotes.after', text, options);
|
2015-01-19 19:37:21 +08:00
|
|
|
return text;
|
2015-01-16 05:21:33 +08:00
|
|
|
});
|