JAVASCRIPT   62

set.js

Guest on 9th September 2021 02:23:53 AM

  1. // -------------------------------------------------------------------
  2. // markItUp!
  3. // -------------------------------------------------------------------
  4. // Copyright (C) 2008 Jay Salvat
  5. // http://markitup.jaysalvat.com/
  6. // -------------------------------------------------------------------
  7. // MarkDown tags example
  8. // http://en.wikipedia.org/wiki/Markdown
  9. // http://daringfireball.net/projects/markdown/
  10. // -------------------------------------------------------------------
  11. // Feel free to add more tags
  12. // -------------------------------------------------------------------
  13. mySettings = {
  14.         onShiftEnter:           {keepDefault:false, openWith:'\n\n'},
  15.         markupSet: [
  16.                 {name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
  17.                 {name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
  18.                 {name:'Heading 3', key:'3', openWith:'### ', placeHolder:'Your title here...' },
  19.                 {name:'Heading 4', key:'4', openWith:'#### ', placeHolder:'Your title here...' },
  20.                 {name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' },
  21.                 {name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' },
  22.                 {separator:'---------------' },
  23.                 {name:'Bold', key:'B', openWith:'**', closeWith:'**'},
  24.                 {name:'Italic', key:'I', openWith:'_', closeWith:'_'},
  25.                 {separator:'---------------' },
  26.                 {name:'Bulleted List', openWith:'- ' },
  27.                 {name:'Numeric List', openWith:function(markItUp) {
  28.                         return markItUp.line+'. ';
  29.                 }},
  30.                 {separator:'---------------' },
  31.                 {name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
  32.                 {name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' },
  33.                 {separator:'---------------'},
  34.                 {name:'Quotes', openWith:'> '},
  35.                 {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'},
  36.                 {separator:'---------------'},
  37.                 {name:'Preview', call:'preview', className:"preview"}
  38.         ]
  39. }
  40.  
  41. // mIu nameSpace to avoid conflict.
  42. miu = {
  43.         markdownTitle: function(markItUp, achar) {
  44.                 heading = '';
  45.                 n = jQuery.trim(markItUp.selection||markItUp.placeHolder).length;
  46.                 // work around bug in python-markdown where header underlines must be at least 3 chars
  47.                 if (n < 3) { n = 3; }
  48.                 for(i = 0; i < n; i++) {
  49.                         heading += achar;
  50.                 }
  51.                 return '\n'+heading;
  52.         }
  53. }

Raw Paste


Login or Register to edit or fork this paste. It's free.