aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/tiki
diff options
context:
space:
mode:
Diffstat (limited to 'imports/codemirror/mode/tiki')
-rw-r--r--imports/codemirror/mode/tiki/index.html82
-rw-r--r--imports/codemirror/mode/tiki/tiki.css26
-rw-r--r--imports/codemirror/mode/tiki/tiki.js316
3 files changed, 424 insertions, 0 deletions
diff --git a/imports/codemirror/mode/tiki/index.html b/imports/codemirror/mode/tiki/index.html
new file mode 100644
index 00000000..bf800407
--- /dev/null
+++ b/imports/codemirror/mode/tiki/index.html
@@ -0,0 +1,82 @@
1<html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <title>CodeMirror: Tiki wiki mode</title>
4 <link rel="stylesheet" href="../../lib/codemirror.css">
5 <script src="../../lib/codemirror.js"></script>
6 <script src="tiki.js"></script>
7 <link rel="stylesheet" href="tiki.css">
8 <link rel="stylesheet" href="../../doc/docs.css">
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 </head>
11 <body style="padding: 20px;">
12 <h1>CodeMirror: Tiki wiki mode</h1>
13
14<div><textarea id="code" name="code">
15Headings
16!Header 1
17!!Header 2
18!!!Header 3
19!!!!Header 4
20!!!!!Header 5
21!!!!!!Header 6
22
23Styling
24-=titlebar=-
25^^ Box on multi
26lines
27of content^^
28__bold__
29''italic''
30===underline===
31::center::
32--Line Through--
33
34Operators
35~np~No parse~/np~
36
37Link
38[link|desc|nocache]
39
40Wiki
41((Wiki))
42((Wiki|desc))
43((Wiki|desc|timeout))
44
45Table
46||row1 col1|row1 col2|row1 col3
47row2 col1|row2 col2|row2 col3
48row3 col1|row3 col2|row3 col3||
49
50Lists:
51*bla
52**bla-1
53++continue-bla-1
54***bla-2
55++continue-bla-1
56*bla
57+continue-bla
58#bla
59** tra-la-la
60+continue-bla
61#bla
62
63Plugin (standard):
64{PLUGIN(attr="my attr")}
65Plugin Body
66{PLUGIN}
67
68Plugin (inline):
69{plugin attr="my attr"}
70</textarea></div>
71
72<script type="text/javascript">
73 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
74 mode: 'tiki',
75 lineNumbers: true,
76 enterMode: 'keep',
77 matchBrackets: true
78 });
79</script>
80
81</body>
82</html>
diff --git a/imports/codemirror/mode/tiki/tiki.css b/imports/codemirror/mode/tiki/tiki.css
new file mode 100644
index 00000000..e3c3c0fd
--- /dev/null
+++ b/imports/codemirror/mode/tiki/tiki.css
@@ -0,0 +1,26 @@
1.cm-tw-syntaxerror {
2 color: #FFFFFF;
3 background-color: #990000;
4}
5
6.cm-tw-deleted {
7 text-decoration: line-through;
8}
9
10.cm-tw-header5 {
11 font-weight: bold;
12}
13.cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/
14 padding-left: 10px;
15}
16
17.cm-tw-box {
18 border-top-width: 0px ! important;
19 border-style: solid;
20 border-width: 1px;
21 border-color: inherit;
22}
23
24.cm-tw-underline {
25 text-decoration: underline;
26} \ No newline at end of file
diff --git a/imports/codemirror/mode/tiki/tiki.js b/imports/codemirror/mode/tiki/tiki.js
new file mode 100644
index 00000000..350dd51b
--- /dev/null
+++ b/imports/codemirror/mode/tiki/tiki.js
@@ -0,0 +1,316 @@
1CodeMirror.defineMode('tiki', function(config, parserConfig) {
2 function inBlock(style, terminator, returnTokenizer) {
3 return function(stream, state) {
4 while (!stream.eol()) {
5 if (stream.match(terminator)) {
6 state.tokenize = inText;
7 break;
8 }
9 stream.next();
10 }
11
12 if (returnTokenizer) state.tokenize = returnTokenizer;
13
14 return style;
15 };
16 }
17
18 function inLine(style, terminator) {
19 return function(stream, state) {
20 while(!stream.eol()) {
21 stream.next()
22 }
23 state.tokenize = inText;
24 return style;
25 };
26 }
27
28 function inText(stream, state) {
29 function chain(parser) {
30 state.tokenize = parser;
31 return parser(stream, state);
32 }
33
34 var sol = stream.sol();
35 var ch = stream.next();
36
37 //non start of line
38 switch (ch) { //switch is generally much faster than if, so it is used here
39 case "{": //plugin
40 type = stream.eat("/") ? "closeTag" : "openTag";
41 stream.eatSpace();
42 tagName = "";
43 var c;
44 while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
45 state.tokenize = inPlugin;
46 return "tag";
47 break;
48 case "_": //bold
49 if (stream.eat("_")) {
50 return chain(inBlock("strong", "__", inText));
51 }
52 break;
53 case "'": //italics
54 if (stream.eat("'")) {
55 // Italic text
56 return chain(inBlock("em", "''", inText));
57 }
58 break;
59 case "(":// Wiki Link
60 if (stream.eat("(")) {
61 return chain(inBlock("variable-2", "))", inText));
62 }
63 break;
64 case "[":// Weblink
65 return chain(inBlock("variable-3", "]", inText));
66 break;
67 case "|": //table
68 if (stream.eat("|")) {
69 return chain(inBlock("comment", "||"));
70 }
71 break;
72 case "-":
73 if (stream.eat("=")) {//titleBar
74 return chain(inBlock("header string", "=-", inText));
75 } else if (stream.eat("-")) {//deleted
76 return chain(inBlock("error tw-deleted", "--", inText));
77 }
78 break;
79 case "=": //underline
80 if (stream.match("==")) {
81 return chain(inBlock("tw-underline", "===", inText));
82 }
83 break;
84 case ":":
85 if (stream.eat(":")) {
86 return chain(inBlock("comment", "::"));
87 }
88 break;
89 case "^": //box
90 return chain(inBlock("tw-box", "^"));
91 break;
92 case "~": //np
93 if (stream.match("np~")) {
94 return chain(inBlock("meta", "~/np~"));
95 }
96 break;
97 }
98
99 //start of line types
100 if (sol) {
101 switch (ch) {
102 case "!": //header at start of line
103 if (stream.match('!!!!!')) {
104 return chain(inLine("header string"));
105 } else if (stream.match('!!!!')) {
106 return chain(inLine("header string"));
107 } else if (stream.match('!!!')) {
108 return chain(inLine("header string"));
109 } else if (stream.match('!!')) {
110 return chain(inLine("header string"));
111 } else {
112 return chain(inLine("header string"));
113 }
114 break;
115 case "*": //unordered list line item, or <li /> at start of line
116 case "#": //ordered list line item, or <li /> at start of line