Browse files

Combined & Minified

  • Loading branch information...
1 parent dc29572 commit ba5a99fddd047e4d4e3bf1739345062663348804 @ChiperSoft ChiperSoft committed May 5, 2011
Showing with 15 additions and 7 deletions.
  1. +12 −5 wmd.combined.js
  2. +3 −2 wmd.combined.min.js
View
17 wmd.combined.js
@@ -64,7 +64,7 @@
tagFilter: {
- enabled: true,
+ enabled: false,
allowedTags: /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i,
patternLink: /^(<a\shref=("|')(\#\d+|(https?:\/\/|ftp:\/\/|mailto:)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)\2(\stitle="[^"<>]+")?\s?>|<\/a>)$/i,
patternImage: /^(<img\ssrc="https?:(\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i
@@ -3292,11 +3292,18 @@ Showdown.converter = function () {
var _DoItalicsAndBold = function (text) {
- // <strong> must go first:
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, "<strong>$2</strong>");
+ if (true) { //eventually this will be replaced with a runtime option. But for now we're forcing it.
+ text = text.replace(/(\*\*)(?=\S)([^\r]*?\S[*]*)\1/g, "<strong>$2</strong>");
+ text = text.replace(/(\w)_(\w)/g, "$1~E95E$2"); // ** GFM ** "~E95E" == escaped "_"
+ text = text.replace(/(\*)(?=\S)([^\r]*?\S)\1/g, "<em>$2</em>");
+ text = text.replace(/(_)(?=\S)([^\r]*?\S)\1/g, "<u>$2</u>");
+ } else {
+ // <strong> must go first:
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, "<strong>$2</strong>");
- text = text.replace(/(\w)_(\w)/g, "$1~E95E$2"); // ** GFM ** "~E95E" == escaped "_"
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, "<em>$2</em>");
+ text = text.replace(/(\w)_(\w)/g, "$1~E95E$2"); // ** GFM ** "~E95E" == escaped "_"
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, "<em>$2</em>");
+ }
return text;
};
View
5 wmd.combined.min.js
@@ -1,4 +1,4 @@
-;(function(){WMDEditor=function(options){this.options=WMDEditor.util.extend({},WMDEditor.defaults,options||{});wmdBase(this,this.options);this.startEditor();};window.WMDEditor=WMDEditor;WMDEditor.defaults={version:2.1,output_format:"markdown",lineLength:40,button_bar:"wmd-button-bar",preview:"wmd-preview",output:"wmd-output",input:"wmd-input",imageDialogText:"<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://i.imgur.com/1cZl4.jpg</p>",linkDialogText:"<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://www.google.com/</p>",imageDefaultText:"http://",linkDefaultText:"http://",imageDirectory:"images/",helpLink:"/wmd/markdownhelp.html",helpHoverTitle:"Markdown Syntax",helpTarget:"_blank",previewPollInterval:500,pastePollInterval:100,buttons:"bold italic link blockquote code image ol ul heading hr undo redo help",autoFormatting:{list:true,quote:true,code:true,},modifierKeys:{bold:"b",italic:"i",link:"l",quote:"q",code:"k",image:"g",orderedList:"o",unorderedList:"u",heading:"h",horizontalRule:"r",redo:"y",undo:"z"},tagFilter:{enabled:true,allowedTags:/^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i,patternLink:/^(<a\shref=("|')(\#\d+|(https?:\/\/|ftp:\/\/|mailto:)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)\2(\stitle="[^"<>]+")?\s?>|<\/a>)$/i,patternImage:/^(<img\ssrc="https?:(\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i}};WMDEditor.prototype={getPanels:function(){return{buttonBar:(typeof this.options.button_bar=='string')?document.getElementById(this.options.button_bar):this.options.button_bar,preview:(typeof this.options.preview=='string')?document.getElementById(this.options.preview):this.options.preview,output:(typeof this.options.output=='string')?document.getElementById(this.options.output):this.options.output,input:(typeof this.options.input=='string')?document.getElementById(this.options.input):this.options.input};},startEditor:function(){this.panels=this.getPanels();this.previewMgr=new PreviewManager(this);edit=new this.editor(this.previewMgr.refresh);this.previewMgr.refresh(true);}};var util={isVisible:function(elem){return elem.offsetWidth>0||elem.offsetHeight>0;},addEvent:function(elem,event,listener){if(elem.attachEvent){elem.attachEvent("on"+event,listener);}
+;(function(){WMDEditor=function(options){this.options=WMDEditor.util.extend({},WMDEditor.defaults,options||{});wmdBase(this,this.options);this.startEditor();};window.WMDEditor=WMDEditor;WMDEditor.defaults={version:2.1,output_format:"markdown",lineLength:40,button_bar:"wmd-button-bar",preview:"wmd-preview",output:"wmd-output",input:"wmd-input",imageDialogText:"<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://i.imgur.com/1cZl4.jpg</p>",linkDialogText:"<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://www.google.com/</p>",imageDefaultText:"http://",linkDefaultText:"http://",imageDirectory:"images/",helpLink:"/wmd/markdownhelp.html",helpHoverTitle:"Markdown Syntax",helpTarget:"_blank",previewPollInterval:500,pastePollInterval:100,buttons:"bold italic link blockquote code image ol ul heading hr undo redo help",autoFormatting:{list:true,quote:true,code:true,},modifierKeys:{bold:"b",italic:"i",link:"l",quote:"q",code:"k",image:"g",orderedList:"o",unorderedList:"u",heading:"h",horizontalRule:"r",redo:"y",undo:"z"},tagFilter:{enabled:false,allowedTags:/^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i,patternLink:/^(<a\shref=("|')(\#\d+|(https?:\/\/|ftp:\/\/|mailto:)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)\2(\stitle="[^"<>]+")?\s?>|<\/a>)$/i,patternImage:/^(<img\ssrc="https?:(\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i}};WMDEditor.prototype={getPanels:function(){return{buttonBar:(typeof this.options.button_bar=='string')?document.getElementById(this.options.button_bar):this.options.button_bar,preview:(typeof this.options.preview=='string')?document.getElementById(this.options.preview):this.options.preview,output:(typeof this.options.output=='string')?document.getElementById(this.options.output):this.options.output,input:(typeof this.options.input=='string')?document.getElementById(this.options.input):this.options.input};},startEditor:function(){this.panels=this.getPanels();this.previewMgr=new PreviewManager(this);edit=new this.editor(this.previewMgr.refresh);this.previewMgr.refresh(true);}};var util={isVisible:function(elem){return elem.offsetWidth>0||elem.offsetHeight>0;},addEvent:function(elem,event,listener){if(elem.attachEvent){elem.attachEvent("on"+event,listener);}
else{elem.addEventListener(event,listener,false);}},removeEvent:function(elem,event,listener){if(elem.detachEvent){elem.detachEvent("on"+event,listener);}
else{elem.removeEventListener(event,listener,false);}},fixEolChars:function(text){text=text.replace(/\r\n/g,"\n");text=text.replace(/\r/g,"\n");return text;},extendRegExp:function(regex,pre,post){if(pre===null||pre===undefined){pre="";}
if(post===null||post===undefined){post="";}
@@ -178,7 +178,8 @@ else{return whole_match;}}
alt_text=alt_text.replace(/"/g,"&quot;");url=escapeCharacters(url,"*_");var result="<img src=\""+url+"\" alt=\""+alt_text+"\"";title=title.replace(/"/g,"&quot;");title=escapeCharacters(title,"*_");result+=" title=\""+title+"\"";result+=" />";return result;};var _DoHeaders=function(text){text=text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(wholeMatch,m1){return hashBlock("<h1>"+_RunSpanGamut(m1)+"</h1>");});text=text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(matchFound,m1){return hashBlock("<h2>"+_RunSpanGamut(m1)+"</h2>");});text=text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(wholeMatch,m1,m2){var h_level=m1.length;return hashBlock("<h"+h_level+">"+_RunSpanGamut(m2)+"</h"+h_level+">");});return text;};var _ProcessListItems;var _DoLists=function(text){text+="~0";var whole_list=/^(([ ]{0,3}([*+\-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+\-]|\d+[.])[ \t]+)))/gm;if(g_list_level){text=text.replace(whole_list,function(wholeMatch,m1,m2){var list=m1;var list_type=(m2.search(/[*+\-]/g)>-1)?"ul":"ol";list=list.replace(/\n{2,}/g,"\n\n\n");var result=_ProcessListItems(list);result=result.replace(/\s+$/,"");result="<"+list_type+">"+result+"</"+list_type+">\n";return result;});}else{whole_list=/(\n\n|^\n?)(([ ]{0,3}([*+\-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+\-]|\d+[.])[ \t]+)))/g;text=text.replace(whole_list,function(wholeMatch,m1,m2,m3){var runup=m1;var list=m2;var list_type=(m3.search(/[*+\-]/g)>-1)?"ul":"ol";list=list.replace(/\n{2,}/g,"\n\n\n");var result=_ProcessListItems(list);result=runup+"<"+list_type+">\n"+result+"</"+list_type+">\n";return result;});}
text=text.replace(/~0/,"");return text;};_ProcessListItems=function(list_str){g_list_level++;list_str=list_str.replace(/\n{2,}$/,"\n");list_str+="~0";list_str=list_str.replace(/(\n)?(^[ \t]*)([*+\-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+\-]|\d+[.])[ \t]+))/gm,function(wholeMatch,m1,m2,m3,m4){var item=m4;var leading_line=m1;var leading_space=m2;if(leading_line||(item.search(/\n{2,}/)>-1)){item=_RunBlockGamut(_Outdent(item));}
else{item=_DoLists(_Outdent(item));item=item.replace(/\n$/,"");item=_RunSpanGamut(item);}
-return"<li>"+item+"</li>\n";});list_str=list_str.replace(/~0/g,"");g_list_level--;return list_str;};var _DoCodeBlocks=function(text){text+="~0";text=text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(wholeMatch,m1,m2){var codeblock=m1;var nextChar=m2;codeblock=_EncodeCode(_Outdent(codeblock));codeblock=_Detab(codeblock);codeblock=codeblock.replace(/^\n+/g,"");codeblock=codeblock.replace(/\n+$/g,"");codeblock="<pre><code>"+codeblock+"\n</code></pre>";return hashBlock(codeblock)+nextChar;});text=text.replace(/~0/,"");return text;};var hashBlock=function(text){text=text.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(g_html_blocks.push(text)-1)+"K\n\n";};var _DoCodeSpans=function(text){text=text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<code>"+c+"</code>";});text=text.replace(/(^|[^\\])(\^{2})([^\r]*?[^\^]{2})\2(?!\^)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<sup>"+c+"</sup>";});text=text.replace(/(^|[^\\])(,{2})([^\r]*?[^,]{2})\2(?!,)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<sub>"+c+"</sub>";});text=text.replace(/(^|[^\\])(~T~T)([^\r]*?[^~]{2})\2(?!~)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<strike>"+c+"</strike>";});return text;};var _EncodeCode=function(text){text=text.replace(/&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");text=text.replace(/\u2026/g,'&hellip;').replace(/\u00AB/g,'&laquo;').replace(/\u00BB/g,'&raquo;').replace(/\u201C/g,'&ldquo;').replace(/\u201D/g,'&rdquo;').replace(/\u2018/g,'&lsquo;').replace(/\u2019/g,'&rsquo;').replace(/\u2014/g,'&mdash;').replace(/\u2013/g,'&ndash;').replace(/\u2022/g,'&bull;').replace(/\u2122/g,'&trade;').replace(/\u00A9/g,'&copy;').replace(/\u00AE/g,'&reg;');text=escapeCharacters(text,"*_{}[]\\",false);return text;};var _DoItalicsAndBold=function(text){text=text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");text=text.replace(/(\w)_(\w)/g,"$1~E95E$2");text=text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");return text;};var _DoBlockQuotes=function(text){text=text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(wholeMatch,m1){var bq=m1;bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");bq=bq.replace(/~0/g,"");bq=bq.replace(/^[ \t]+$/gm,"");bq=_RunBlockGamut(bq);bq=bq.replace(/(^|\n)/g,"$1 ");bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(wholeMatch,m1){var pre=m1;pre=pre.replace(/^ {2}/mg,"~0");pre=pre.replace(/~0/g,"");return pre;});return hashBlock("<blockquote>\n"+bq+"\n</blockquote>");});return text;};var _FormParagraphs=function(text){text=text.replace(/^\n+/g,"");text=text.replace(/\n+$/g,"");var i;var grafs=text.split(/\n{2,}/g);var grafsOut=[];var end=grafs.length;for(i=0;i<end;i++){var str=grafs[i];var p_tag='<p>';if(str.search(/~K(\d+)K/g)>=0){grafsOut.push(str);}
+return"<li>"+item+"</li>\n";});list_str=list_str.replace(/~0/g,"");g_list_level--;return list_str;};var _DoCodeBlocks=function(text){text+="~0";text=text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(wholeMatch,m1,m2){var codeblock=m1;var nextChar=m2;codeblock=_EncodeCode(_Outdent(codeblock));codeblock=_Detab(codeblock);codeblock=codeblock.replace(/^\n+/g,"");codeblock=codeblock.replace(/\n+$/g,"");codeblock="<pre><code>"+codeblock+"\n</code></pre>";return hashBlock(codeblock)+nextChar;});text=text.replace(/~0/,"");return text;};var hashBlock=function(text){text=text.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(g_html_blocks.push(text)-1)+"K\n\n";};var _DoCodeSpans=function(text){text=text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<code>"+c+"</code>";});text=text.replace(/(^|[^\\])(\^{2})([^\r]*?[^\^]{2})\2(?!\^)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<sup>"+c+"</sup>";});text=text.replace(/(^|[^\\])(,{2})([^\r]*?[^,]{2})\2(?!,)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<sub>"+c+"</sub>";});text=text.replace(/(^|[^\\])(~T~T)([^\r]*?[^~]{2})\2(?!~)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<strike>"+c+"</strike>";});return text;};var _EncodeCode=function(text){text=text.replace(/&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");text=text.replace(/\u2026/g,'&hellip;').replace(/\u00AB/g,'&laquo;').replace(/\u00BB/g,'&raquo;').replace(/\u201C/g,'&ldquo;').replace(/\u201D/g,'&rdquo;').replace(/\u2018/g,'&lsquo;').replace(/\u2019/g,'&rsquo;').replace(/\u2014/g,'&mdash;').replace(/\u2013/g,'&ndash;').replace(/\u2022/g,'&bull;').replace(/\u2122/g,'&trade;').replace(/\u00A9/g,'&copy;').replace(/\u00AE/g,'&reg;');text=escapeCharacters(text,"*_{}[]\\",false);return text;};var _DoItalicsAndBold=function(text){if(true){text=text.replace(/(\*\*)(?=\S)([^\r]*?\S[*]*)\1/g,"<strong>$2</strong>");text=text.replace(/(\w)_(\w)/g,"$1~E95E$2");text=text.replace(/(\*)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");text=text.replace(/(_)(?=\S)([^\r]*?\S)\1/g,"<u>$2</u>");}else{text=text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");text=text.replace(/(\w)_(\w)/g,"$1~E95E$2");text=text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");}
+return text;};var _DoBlockQuotes=function(text){text=text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(wholeMatch,m1){var bq=m1;bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");bq=bq.replace(/~0/g,"");bq=bq.replace(/^[ \t]+$/gm,"");bq=_RunBlockGamut(bq);bq=bq.replace(/(^|\n)/g,"$1 ");bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(wholeMatch,m1){var pre=m1;pre=pre.replace(/^ {2}/mg,"~0");pre=pre.replace(/~0/g,"");return pre;});return hashBlock("<blockquote>\n"+bq+"\n</blockquote>");});return text;};var _FormParagraphs=function(text){text=text.replace(/^\n+/g,"");text=text.replace(/\n+$/g,"");var i;var grafs=text.split(/\n{2,}/g);var grafsOut=[];var end=grafs.length;for(i=0;i<end;i++){var str=grafs[i];var p_tag='<p>';if(str.search(/~K(\d+)K/g)>=0){grafsOut.push(str);}
else if(str.search(/\S/)>=0){str=_RunSpanGamut(str);if(str.substr(0,2)==='->'){if(str.substr(-5)==='&lt;-'){p_tag='<p align="center">';str=str.slice(2,-5);}else{p_tag='<p align="right">';str=str.substring(2);}}
str=str.replace(/\n/g,"<br />");str=str.replace(/^([ \t]*)/g,p_tag);str+="</p>";grafsOut.push(str);}}
end=grafsOut.length;for(i=0;i<end;i++){while(grafsOut[i].search(/~K(\d+)K/)>=0){var blockText=g_html_blocks[RegExp.$1];blockText=blockText.replace(/\$/g,"$$$$");grafsOut[i]=grafsOut[i].replace(/~K\d+K/,blockText);}}

0 comments on commit ba5a99f

Please sign in to comment.