Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 13th, 2012  |  syntax: None  |  size: 7.17 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var Attacklab=Attacklab||{};
  2. Attacklab.wmdPlus=function(){
  3. this.symboltable;
  4. var _1=top;
  5. var _2=_1["Attacklab"];
  6. var _3=_1["document"];
  7. var _4=_1["RegExp"];
  8. var _5=_1["navigator"];
  9. var _6=_2.Util;
  10. var _7=_2.Position;
  11. var _8=_2.Command;
  12. _8.doAutoindent=function(_9){
  13. _9.before=_9.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/,"\n\n");
  14. _9.before=_9.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/,"\n\n");
  15. _9.before=_9.before.replace(/(\n|^)[ \t]+\n$/,"\n\n");
  16. if(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(_9.before)){
  17. if(_8.doList){
  18. _8.doList(_9);
  19. }
  20. }
  21. if(/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(_9.before)){
  22. if(_8.doBlockquote){
  23. _8.doBlockquote(_9);
  24. }
  25. }
  26. if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(_9.before)){
  27. if(_8.doCode){
  28. _8.doCode(_9);
  29. }
  30. }
  31. };
  32. _8.doBlockquote=function(_a){
  33. _a.selection=_a.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(_b,_c,_d,_e){
  34. _a.before+=_c;
  35. _a.after=_e+_a.after;
  36. return _d;
  37. });
  38. _a.before=_a.before.replace(/(>[ \t]*)$/,function(_f,_10){
  39. _a.selection=_10+_a.selection;
  40. return "";
  41. });
  42. _a.selection=_a.selection.replace(/^(\s|>)+$/,"");
  43. _a.selection=_a.selection||"Blockquote";
  44. if(_a.before){
  45. _a.before=_a.before.replace(/\n?$/,"\n");
  46. }
  47. if(_a.after){
  48. _a.after=_a.after.replace(/^\n?/,"\n");
  49. }
  50. _a.before=_a.before.replace(/(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*$)/,function(_11){
  51. _a.startTag=_11;
  52. return "";
  53. });
  54. _a.after=_a.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(_12){
  55. _a.endTag=_12;
  56. return "";
  57. });
  58. var _13=function(_14){
  59. var _15=_14?"> ":"";
  60. if(_a.startTag){
  61. _a.startTag=_a.startTag.replace(/\n((>|\s)*)\n$/,function(_16,_17){
  62. return "\n"+_17.replace(/^[ ]{0,3}>?[ \t]*$/gm,_15)+"\n";
  63. });
  64. }
  65. if(_a.endTag){
  66. _a.endTag=_a.endTag.replace(/^\n((>|\s)*)\n/,function(_18,_19){
  67. return "\n"+_19.replace(/^[ ]{0,3}>?[ \t]*$/gm,_15)+"\n";
  68. });
  69. }
  70. };
  71. if(/^(?![ ]{0,3}>)/m.test(_a.selection)){
  72. _8.wrap(_a,_2.wmd_env.lineLength-2);
  73. _a.selection=_a.selection.replace(/^/gm,"> ");
  74. _13(true);
  75. _a.skipLines();
  76. }else{
  77. _a.selection=_a.selection.replace(/^[ ]{0,3}> ?/gm,"");
  78. _8.unwrap(_a);
  79. _13(false);
  80. if(!/^(\n|^)[ ]{0,3}>/.test(_a.selection)){
  81. if(_a.startTag){
  82. _a.startTag=_a.startTag.replace(/\n{0,2}$/,"\n\n");
  83. }
  84. }
  85. if(!/(\n|^)[ ]{0,3}>.*$/.test(_a.selection)){
  86. if(_a.endTag){
  87. _a.endTag=_a.endTag.replace(/^\n{0,2}/,"\n\n");
  88. }
  89. }
  90. }
  91. if(!/\n/.test(_a.selection)){
  92. _a.selection=_a.selection.replace(/^(> *)/,function(_1a,_1b){
  93. _a.startTag+=_1b;
  94. return "";
  95. });
  96. }
  97. };
  98. _8.doCode=function(_1c){
  99. var _1d=/\S[ ]*$/.test(_1c.before);
  100. var _1e=/^[ ]*\S/.test(_1c.after);
  101. if((!_1e&&!_1d)||/\n/.test(_1c.selection)){
  102. _1c.before=_1c.before.replace(/[ ]{4}$/,function(_1f){
  103. _1c.selection=_1f+_1c.selection;
  104. return "";
  105. });
  106. var _20=1;
  107. var _21=1;
  108. if(/\n(\t|[ ]{4,}).*\n$/.test(_1c.before)){
  109. _20=0;
  110. }
  111. if(/^\n(\t|[ ]{4,})/.test(_1c.after)){
  112. _21=0;
  113. }
  114. _1c.skipLines(_20,_21);
  115. if(!_1c.selection){
  116. _1c.startTag="    ";
  117. _1c.selection="print(\"code sample\");";
  118. return;
  119. }
  120. if(/^[ ]{0,3}\S/m.test(_1c.selection)){
  121. _1c.selection=_1c.selection.replace(/^/gm,"    ");
  122. }else{
  123. _1c.selection=_1c.selection.replace(/^[ ]{4}/gm,"");
  124. }
  125. }else{
  126. _1c.trimWhitespace();
  127. _1c.findTags(/`/,/`/);
  128. if(!_1c.startTag&&!_1c.endTag){
  129. _1c.startTag=_1c.endTag="`";
  130. if(!_1c.selection){
  131. _1c.selection="print(\"code sample\");";
  132. }
  133. }else{
  134. if(_1c.endTag&&!_1c.startTag){
  135. _1c.before+=_1c.endTag;
  136. _1c.endTag="";
  137. }else{
  138. _1c.startTag=_1c.endTag="";
  139. }
  140. }
  141. }
  142. };
  143. _8.autoindent={};
  144. _8.autoindent.textOp=_8.doAutoindent;
  145. _8.blockquote={};
  146. _8.blockquote.description="Blockquote <blockquote>";
  147. _8.blockquote.image="images/blockquote.png";
  148. _8.blockquote.key=".";
  149. _8.blockquote.keyCode=190;
  150. _8.blockquote.textOp=function(_22){
  151. return _8.doBlockquote(_22);
  152. };
  153. _8.code={};
  154. _8.code.description="Code Sample <pre><code>";
  155. _8.code.image="images/code.png";
  156. _8.code.key="k";
  157. _8.code.textOp=_8.doCode;
  158. _8.img={};
  159. _8.img.description="Image <img>";
  160. _8.img.image="images/img.png";
  161. _8.img.key="g";
  162. _8.img.textOp=function(_23,_24){
  163. return _8.doLinkOrImage(_23,true,_24);
  164. };
  165. _8.doList=function(_25,_26){
  166. var _27=/(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/;
  167. var _28="";
  168. var _29=1;
  169. var _2a=function(){
  170. if(_26){
  171. var _2b=" "+_29+". ";
  172. _29++;
  173. return _2b;
  174. }
  175. var _2c=_28||"-";
  176. return "  "+_2c+" ";
  177. };
  178. var _2d=function(_2e){
  179. if(_26==undefined){
  180. _26=/^\s*\d/.test(_2e);
  181. }
  182. _2e=_2e.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(_2f){
  183. return _2a();
  184. });
  185. return _2e;
  186. };
  187. var _30=function(){
  188. _31=_6.regexToString(_27);
  189. _31.expression="^\n*"+_31.expression;
  190. var _32=_6.stringToRegex(_31);
  191. _25.after=_25.after.replace(_32,_2d);
  192. };
  193. _25.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);
  194. var _33=/^\n/;
  195. if(_25.before&&!/\n$/.test(_25.before)&&!_33.test(_25.startTag)){
  196. _25.before+=_25.startTag;
  197. _25.startTag="";
  198. }
  199. if(_25.startTag){
  200. var _34=/\d+[.]/.test(_25.startTag);
  201. _25.startTag="";
  202. _25.selection=_25.selection.replace(/\n[ ]{4}/g,"\n");
  203. _8.unwrap(_25);
  204. _25.skipLines();
  205. if(_34){
  206. _30();
  207. }
  208. if(_26==_34){
  209. return;
  210. }
  211. }
  212. var _35=1;
  213. var _31=_6.regexToString(_27);
  214. _31.expression="(\\n|^)"+_31.expression+"$";
  215. var _36=_6.stringToRegex(_31);
  216. _25.before=_25.before.replace(_36,function(_37){
  217. if(/^\s*([*+-])/.test(_37)){
  218. _28=_4.$1;
  219. }
  220. _35=/[^\n]\n\n[^\n]/.test(_37)?1:0;
  221. return _2d(_37);
  222. });
  223. if(!_25.selection){
  224. _25.selection="List item";
  225. }
  226. var _38=_2a();
  227. var _39=1;
  228. _31=_6.regexToString(_27);
  229. _31.expression="^\n*"+_31.expression;
  230. _36=_6.stringToRegex(_31);
  231. _25.after=_25.after.replace(_36,function(_3a){
  232. _39=/[^\n]\n\n[^\n]/.test(_3a)?1:0;
  233. return _2d(_3a);
  234. });
  235. _25.trimWhitespace(true);
  236. _25.skipLines(_35,_39,true);
  237. _25.startTag=_38;
  238. var _3b=_38.replace(/./g," ");
  239. _8.wrap(_25,_2.wmd_env.lineLength-_3b.length);
  240. _25.selection=_25.selection.replace(/\n/g,"\n"+_3b);
  241. };
  242. _8.doHeading=function(_3c){
  243. _3c.selection=_3c.selection.replace(/\s+/g," ");
  244. _3c.selection=_3c.selection.replace(/(^\s+|\s+$)/g,"");
  245. var _3d=0;
  246. _3c.findTags(/#+[ ]*/,/[ ]*#+/);
  247. if(/#+/.test(_3c.startTag)){
  248. _3d=_4.lastMatch.length;
  249. }
  250. _3c.startTag=_3c.endTag="";
  251. _3c.findTags(null,/\s?(-+|=+)/);
  252. if(/=+/.test(_3c.endTag)){
  253. _3d=1;
  254. }
  255. if(/-+/.test(_3c.endTag)){
  256. _3d=2;
  257. }
  258. _3c.startTag=_3c.endTag="";
  259. _3c.skipLines(1,1);
  260. if(!_3c.selection){
  261. _3c.startTag="## ";
  262. _3c.selection="Heading";
  263. _3c.endTag=" ##";
  264. return;
  265. }
  266. var _3e=_3d==0?2:_3d-1;
  267. if(_3e){
  268. var _3f=_3e>=2?"-":"=";
  269. var _40=_3c.selection.length;
  270. if(_40>_2.wmd_env.lineLength){
  271. _40=_2.wmd_env.lineLength;
  272. }
  273. _3c.endTag="\n";
  274. while(_40--){
  275. _3c.endTag+=_3f;
  276. }
  277. }
  278. };
  279. _8.ol={};
  280. _8.ol.description="Numbered List <ol>";
  281. _8.ol.image="images/ol.png";
  282. _8.ol.key="o";
  283. _8.ol.textOp=function(_41){
  284. _8.doList(_41,true);
  285. };
  286. _8.ul={};
  287. _8.ul.description="Bulleted List <ul>";
  288. _8.ul.image="images/ul.png";
  289. _8.ul.key="u";
  290. _8.ul.textOp=function(_42){
  291. _8.doList(_42,false);
  292. };
  293. _8.h1={};
  294. _8.h1.description="Heading <h1>/<h2>";
  295. _8.h1.image="images/h1.png";
  296. _8.h1.key="h";
  297. _8.h1.textOp=_8.doHeading;
  298. _8.hr={};
  299. _8.hr.description="Horizontal Rule <hr>";
  300. _8.hr.image="images/hr.png";
  301. _8.hr.key="r";
  302. _8.hr.textOp=function(_43){
  303. _43.startTag="----------\n";
  304. _43.selection="";
  305. _43.skipLines(2,1,true);
  306. };
  307. };
  308. if(Attacklab.fileLoaded){
  309. Attacklab.fileLoaded("wmd-plus.js");
  310. }