hashElement.js 540 B

12345678910111213141516171819
  1. showdown.subParser('hashElement', function (text, options, globals) {
  2. 'use strict';
  3. return function (wholeMatch, m1) {
  4. var blockText = m1;
  5. // Undo double lines
  6. blockText = blockText.replace(/\n\n/g, '\n');
  7. blockText = blockText.replace(/^\n/, '');
  8. // strip trailing blank lines
  9. blockText = blockText.replace(/\n+$/g, '');
  10. // Replace the element text with a marker ("~KxK" where x is its key)
  11. blockText = '\n\n~K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
  12. return blockText;
  13. };
  14. });