|
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 previewParserPath: '', |
|
15 onShiftEnter: {keepDefault:false, openWith:'\n\n'}, |
|
16 markupSet: [ |
|
17 {name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } }, |
|
18 {name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } }, |
|
19 {name:'Heading 3', key:'3', openWith:'### ', placeHolder:'Your title here...' }, |
|
20 {name:'Heading 4', key:'4', openWith:'#### ', placeHolder:'Your title here...' }, |
|
21 {name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' }, |
|
22 {name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' }, |
|
23 {separator:'---------------' }, |
|
24 {name:'Bold', key:'B', openWith:'**', closeWith:'**'}, |
|
25 {name:'Italic', key:'I', openWith:'_', closeWith:'_'}, |
|
26 {separator:'---------------' }, |
|
27 {name:'Bulleted List', openWith:'- ' }, |
|
28 {name:'Numeric List', openWith:function(markItUp) { |
|
29 return markItUp.line+'. '; |
|
30 }}, |
|
31 {separator:'---------------' }, |
|
32 {name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'}, |
|
33 {name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' }, |
|
34 {separator:'---------------'}, |
|
35 {name:'Quotes', openWith:'> '}, |
|
36 {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'}, |
|
37 {separator:'---------------'}, |
|
38 {name:'Preview', call:'preview', className:"preview"} |
|
39 ] |
|
40 } |
|
41 |
|
42 // mIu nameSpace to avoid conflict. |
|
43 miu = { |
|
44 markdownTitle: function(markItUp, char) { |
|
45 heading = ''; |
|
46 n = $.trim(markItUp.selection||markItUp.placeHolder).length; |
|
47 for(i = 0; i < n; i++) { |
|
48 heading += char; |
|
49 } |
|
50 return '\n'+heading; |
|
51 } |
|
52 } |