/** * Created by Estevao on 12-01-2015. */ /** * */ showdown.subParser('paragraphs', function (text, options, globals) { 'use strict'; // Strip leading and trailing lines: text = text.replace(/^\n+/g, ''); text = text.replace(/\n+$/g, ''); var grafs = text.split(/\n{2,}/g), grafsOut = []; /** Wrap

tags. */ var end = grafs.length; for (var i = 0; i < end; i++) { var str = grafs[i]; // if this is an HTML marker, copy it if (str.search(/~K(\d+)K/g) >= 0) { grafsOut.push(str); } else if (str.search(/\S/) >= 0) { str = showdown.subParser('spanGamut')(str, options, globals); str = str.replace(/^([ \t]*)/g, '

'); str += '

'; grafsOut.push(str); } } /** Unhashify HTML blocks */ end = grafsOut.length; for (i = 0; i < end; i++) { // if this is a marker for an html block... while (grafsOut[i].search(/~K(\d+)K/) >= 0) { var blockText = globals.gHtmlBlocks[RegExp.$1]; blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs grafsOut[i] = grafsOut[i].replace(/~K\d+K/, blockText); } } return grafsOut.join('\n\n'); });