blockQuotes.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. showdown.subParser('makehtml.blockQuotes', function (text, options, globals) {
  2. 'use strict';
  3. text = globals.converter._dispatch('makehtml.blockQuotes.before', text, options, globals);
  4. text = text.replace(/((^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) {
  5. var bq = m1;
  6. // attacklab: hack around Konqueror 3.5.4 bug:
  7. // "----------bug".replace(/^-/g,"") == "bug"
  8. bq = bq.replace(/^[ \t]*>[ \t]?/gm, '¨0'); // trim one level of quoting
  9. // attacklab: clean up hack
  10. bq = bq.replace(/¨0/g, '');
  11. bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
  12. bq = showdown.subParser('makehtml.githubCodeBlocks')(bq, options, globals);
  13. bq = showdown.subParser('makehtml.blockGamut')(bq, options, globals); // recurse
  14. bq = bq.replace(/(^|\n)/g, '$1 ');
  15. // These leading spaces screw with <pre> content, so we need to fix that:
  16. bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
  17. var pre = m1;
  18. // attacklab: hack around Konqueror 3.5.4 bug:
  19. pre = pre.replace(/^ /mg, '¨0');
  20. pre = pre.replace(/¨0/g, '');
  21. return pre;
  22. });
  23. return showdown.subParser('makehtml.hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
  24. });
  25. text = globals.converter._dispatch('makehtml.blockQuotes.after', text, options, globals);
  26. return text;
  27. });