showdown/src/subParsers/hashElement.js

20 lines
542 B
JavaScript
Raw Normal View History

2015-01-16 05:21:33 +08:00
showdown.subParser('hashElement', function (text, options, globals) {
2015-01-19 19:37:21 +08:00
'use strict';
2015-01-16 05:21:33 +08:00
2015-01-19 19:37:21 +08:00
return function (wholeMatch, m1) {
var blockText = m1;
2015-01-16 05:21:33 +08:00
2015-01-19 19:37:21 +08:00
// Undo double lines
blockText = blockText.replace(/\n\n/g, '\n');
blockText = blockText.replace(/^\n/, '');
2015-01-16 05:21:33 +08:00
2015-01-19 19:37:21 +08:00
// strip trailing blank lines
blockText = blockText.replace(/\n+$/g, '');
2015-01-16 05:21:33 +08:00
// Replace the element text with a marker ("¨KxK" where x is its key)
blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
2015-01-16 05:21:33 +08:00
2015-01-19 19:37:21 +08:00
return blockText;
};
2015-01-16 05:21:33 +08:00
});