-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-
- Loading branch information
Showing
8 changed files
with
602 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
plugins/ED_tinyMCE/tinymce/plugins/codemirror/CodeMirror/mode/django/django.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
(function(CodeMirror) { | ||
"use strict"; | ||
|
||
CodeMirror.defineMode("django:inner", function() { | ||
var keywords = ["block", "endblock", "for", "endfor", "in", "true", "false", | ||
"loop", "none", "self", "super", "if", "endif", "as", "not", "and", | ||
"else", "import", "with", "endwith", "without", "context", "ifequal", "endifequal", | ||
"ifnotequal", "endifnotequal", "extends", "include", "load", "length", "comment", | ||
"endcomment", "empty"]; | ||
keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b"); | ||
|
||
function tokenBase (stream, state) { | ||
stream.eatWhile(/[^\{]/); | ||
var ch = stream.next(); | ||
if (ch == "{") { | ||
if (ch = stream.eat(/\{|%|#/)) { | ||
state.tokenize = inTag(ch); | ||
return "tag"; | ||
} | ||
} | ||
} | ||
function inTag (close) { | ||
if (close == "{") { | ||
close = "}"; | ||
} | ||
return function (stream, state) { | ||
var ch = stream.next(); | ||
if ((ch == close) && stream.eat("}")) { | ||
state.tokenize = tokenBase; | ||
return "tag"; | ||
} | ||
if (stream.match(keywords)) { | ||
return "keyword"; | ||
} | ||
return close == "#" ? "comment" : "string"; | ||
}; | ||
} | ||
return { | ||
startState: function () { | ||
return {tokenize: tokenBase}; | ||
}, | ||
token: function (stream, state) { | ||
return state.tokenize(stream, state); | ||
} | ||
}; | ||
}); | ||
|
||
CodeMirror.defineMode("django", function(config) { | ||
var htmlBase = CodeMirror.getMode(config, "text/html"); | ||
var djangoInner = CodeMirror.getMode(config, "django:inner"); | ||
return CodeMirror.overlayMode(htmlBase, djangoInner); | ||
}); | ||
|
||
CodeMirror.defineMIME("text/x-django", "django"); | ||
})(CodeMirror); |
63 changes: 63 additions & 0 deletions
63
plugins/ED_tinyMCE/tinymce/plugins/codemirror/CodeMirror/mode/django/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!doctype html> | ||
|
||
<title>CodeMirror: Django template mode</title> | ||
<meta charset="utf-8"/> | ||
<link rel=stylesheet href="../../doc/docs.css"> | ||
|
||
<link rel="stylesheet" href="../../lib/codemirror.css"> | ||
<script src="../../lib/codemirror.js"></script> | ||
<script src="../../addon/mode/overlay.js"></script> | ||
<script src="../xml/xml.js"></script> | ||
<script src="../htmlmixed/htmlmixed.js"></script> | ||
<script src="django.js"></script> | ||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> | ||
<div id=nav> | ||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a> | ||
|
||
<ul> | ||
<li><a href="../../index.html">Home</a> | ||
<li><a href="../../doc/manual.html">Manual</a> | ||
<li><a href="https://github.com/marijnh/codemirror">Code</a> | ||
</ul> | ||
<ul> | ||
<li><a href="../index.html">Language modes</a> | ||
<li><a class=active href="#">Django</a> | ||
</ul> | ||
</div> | ||
|
||
<article> | ||
<h2>Django template mode</h2> | ||
<form><textarea id="code" name="code"> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>My Django web application</title> | ||
</head> | ||
<body> | ||
<h1> | ||
{{ page.title }} | ||
</h1> | ||
<ul class="my-list"> | ||
{% for item in items %} | ||
<li>{% item.name %}</li> | ||
{% empty %} | ||
<li>You have no items in your list.</li> | ||
{% endfor %} | ||
</ul> | ||
</body> | ||
</html> | ||
</textarea></form> | ||
|
||
<script> | ||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
lineNumbers: true, | ||
mode: "django", | ||
indentUnit: 4, | ||
indentWithTabs: true | ||
}); | ||
</script> | ||
|
||
<p>Mode for HTML with embedded Django template markup.</p> | ||
|
||
<p><strong>MIME types defined:</strong> <code>text/x-django</code></p> | ||
</article> |
145 changes: 145 additions & 0 deletions
145
plugins/ED_tinyMCE/tinymce/plugins/codemirror/CodeMirror/mode/php/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
(function() { | ||
var mode = CodeMirror.getMode({indentUnit: 2}, "php"); | ||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } | ||
|
||
MT('simple_test', | ||
'[meta <?php] ' + | ||
'[keyword echo] [string "aaa"]; ' + | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_non_alphanumeric', | ||
'[meta <?php]', | ||
'[keyword echo] [string "aaa$~$!$@$#$$$%$^$&$*$($)$.$<$>$/$\\$}$\\\"$:$;$?$|$[[$]]$+$=aaa"]', | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_digits', | ||
'[meta <?php]', | ||
'[keyword echo] [string "aaa$1$2$3$4$5$6$7$8$9$0aaa"]', | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_simple_syntax_1', | ||
'[meta <?php]', | ||
'[keyword echo] [string "aaa][variable-2 $aaa][string .aaa"];', | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_simple_syntax_2', | ||
'[meta <?php]', | ||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2]', ']][string aa"];', | ||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2345]', ']][string aa"];', | ||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];', | ||
'[keyword echo] [string "][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];', | ||
'[keyword echo] [string "][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];', | ||
|
||
'[keyword echo] [string "1aaa][variable-2 $aaaa][[','[number 2]', ']][string aa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2345]', ']][string aa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];', | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_simple_syntax_3', | ||
'[meta <?php]', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string .aaaaaa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa][string ->][variable-2 $aaaaa][string .aaaaaa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string [[2]].aaaaaa"];', | ||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string ->aaaa2.aaaaaa"];', | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_escaping', | ||
'[meta <?php] [comment /* Escaping */]', | ||
'[keyword echo] [string "aaa\\$aaaa->aaa.aaa"];', | ||
'[keyword echo] [string "aaa\\$aaaa[[2]]aaa.aaa"];', | ||
'[keyword echo] [string "aaa\\$aaaa[[asd]]aaa.aaa"];', | ||
'[keyword echo] [string "aaa{\\$aaaa->aaa.aaa"];', | ||
'[keyword echo] [string "aaa{\\$aaaa[[2]]aaa.aaa"];', | ||
'[keyword echo] [string "aaa{\\aaaaa[[asd]]aaa.aaa"];', | ||
'[keyword echo] [string "aaa\\${aaaa->aaa.aaa"];', | ||
'[keyword echo] [string "aaa\\${aaaa[[2]]aaa.aaa"];', | ||
'[keyword echo] [string "aaa\\${aaaa[[asd]]aaa.aaa"];', | ||
'[meta ?>]'); | ||
|
||
MT('variable_interpolation_complex_syntax_1', | ||
'[meta <?php]', | ||
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa]}[string ->aaa.aaa"];', | ||
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa]}[string ->aaa.aaa"];', | ||
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa][[',' [number 42]',']]}[string ->aaa.aaa"];', | ||
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa][meta ?>]aaaaaa'); | ||
|
||
MT('variable_interpolation_complex_syntax_2', | ||
'[meta <?php] [comment /* Monsters */]', | ||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>} $aaa<?php } */]}[string ->aaa.aaa"];', | ||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>*/][[',' [string "aaa][variable-2 $aaa][string {}][variable-2 $]{[variable aaa]}[string "]',']]}[string ->aaa.aaa"];', | ||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*} } $aaa } */]}[string ->aaa.aaa"];'); | ||
|
||
|
||
function build_recursive_monsters(nt, t, n){ | ||
var monsters = [t]; | ||
for (var i = 1; i <= n; ++i) | ||
monsters[i] = nt.join(monsters[i - 1]); | ||
return monsters; | ||
} | ||
|
||
var m1 = build_recursive_monsters( | ||
['[string "][variable-2 $]{[variable aaa] [operator +] ', '}[string "]'], | ||
'[comment /* }?>} */] [string "aaa][variable-2 $aaa][string .aaa"]', | ||
10 | ||
); | ||
|
||
MT('variable_interpolation_complex_syntax_3_1', | ||
'[meta <?php] [comment /* Recursive monsters */]', | ||
'[keyword echo] ' + m1[4] + ';', | ||
'[keyword echo] ' + m1[7] + ';', | ||
'[keyword echo] ' + m1[8] + ';', | ||
'[keyword echo] ' + m1[5] + ';', | ||
'[keyword echo] ' + m1[1] + ';', | ||
'[keyword echo] ' + m1[6] + ';', | ||
'[keyword echo] ' + m1[9] + ';', | ||
'[keyword echo] ' + m1[0] + ';', | ||
'[keyword echo] ' + m1[10] + ';', | ||
'[keyword echo] ' + m1[2] + ';', | ||
'[keyword echo] ' + m1[3] + ';', | ||
'[keyword echo] [string "end"];', | ||
'[meta ?>]'); | ||
|
||
var m2 = build_recursive_monsters( | ||
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', '}[string .a"]'], | ||
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]', | ||
5 | ||
); | ||
|
||
MT('variable_interpolation_complex_syntax_3_2', | ||
'[meta <?php] [comment /* Recursive monsters 2 */]', | ||
'[keyword echo] ' + m2[0] + ';', | ||
'[keyword echo] ' + m2[1] + ';', | ||
'[keyword echo] ' + m2[5] + ';', | ||
'[keyword echo] ' + m2[4] + ';', | ||
'[keyword echo] ' + m2[2] + ';', | ||
'[keyword echo] ' + m2[3] + ';', | ||
'[keyword echo] [string "end"];', | ||
'[meta ?>]'); | ||
|
||
function build_recursive_monsters_2(mf1, mf2, nt, t, n){ | ||
var monsters = [t]; | ||
for (var i = 1; i <= n; ++i) | ||
monsters[i] = nt[0] + mf1[i - 1] + nt[1] + mf2[i - 1] + nt[2] + monsters[i - 1] + nt[3]; | ||
return monsters; | ||
} | ||
|
||
var m3 = build_recursive_monsters_2( | ||
m1, | ||
m2, | ||
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', ' [operator +] ', '}[string .a"]'], | ||
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]', | ||
4 | ||
); | ||
|
||
MT('variable_interpolation_complex_syntax_3_3', | ||
'[meta <?php] [comment /* Recursive monsters 2 */]', | ||
'[keyword echo] ' + m3[4] + ';', | ||
'[keyword echo] ' + m3[0] + ';', | ||
'[keyword echo] ' + m3[3] + ';', | ||
'[keyword echo] ' + m3[1] + ';', | ||
'[keyword echo] ' + m3[2] + ';', | ||
'[keyword echo] [string "end"];', | ||
'[meta ?>]'); | ||
})(); |
114 changes: 114 additions & 0 deletions
114
plugins/ED_tinyMCE/tinymce/plugins/codemirror/CodeMirror/mode/verilog/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
(function() { | ||
var mode = CodeMirror.getMode({indentUnit: 4}, "verilog"); | ||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } | ||
|
||
MT("Binary literals", | ||
"[number 1'b0]", | ||
"[number 1'b1]", | ||
"[number 1'bx]", | ||
"[number 1'bz]", | ||
"[number 1'bX]", | ||
"[number 1'bZ]", | ||
"[number 1'B0]", | ||
"[number 1'B1]", | ||
"[number 1'Bx]", | ||
"[number 1'Bz]", | ||
"[number 1'BX]", | ||
"[number 1'BZ]", | ||
"[number 1'b0]", | ||
"[number 1'b1]", | ||
"[number 2'b01]", | ||
"[number 2'bxz]", | ||
"[number 2'b11]", | ||
"[number 2'b10]", | ||
"[number 2'b1Z]", | ||
"[number 12'b0101_0101_0101]", | ||
"[number 1'b 0]", | ||
"[number 'b0101]" | ||
); | ||
|
||
MT("Octal literals", | ||
"[number 3'o7]", | ||
"[number 3'O7]", | ||
"[number 3'so7]", | ||
"[number 3'SO7]" | ||
); | ||
|
||
MT("Decimal literals", | ||
"[number 0]", | ||
"[number 1]", | ||
"[number 7]", | ||
"[number 123_456]", | ||
"[number 'd33]", | ||
"[number 8'd255]", | ||
"[number 8'D255]", | ||
"[number 8'sd255]", | ||
"[number 8'SD255]", | ||
"[number 32'd123]", | ||
"[number 32 'd123]", | ||
"[number 32 'd 123]" | ||
); | ||
|
||
MT("Hex literals", | ||
"[number 4'h0]", | ||
"[number 4'ha]", | ||
"[number 4'hF]", | ||
"[number 4'hx]", | ||
"[number 4'hz]", | ||
"[number 4'hX]", | ||
"[number 4'hZ]", | ||
"[number 32'hdc78]", | ||
"[number 32'hDC78]", | ||
"[number 32 'hDC78]", | ||
"[number 32'h DC78]", | ||
"[number 32 'h DC78]", | ||
"[number 32'h44x7]", | ||
"[number 32'hFFF?]" | ||
); | ||
|
||
MT("Real number literals", | ||
"[number 1.2]", | ||
"[number 0.1]", | ||
"[number 2394.26331]", | ||
"[number 1.2E12]", | ||
"[number 1.2e12]", | ||
"[number 1.30e-2]", | ||
"[number 0.1e-0]", | ||
"[number 23E10]", | ||
"[number 29E-2]", | ||
"[number 236.123_763_e-12]" | ||
); | ||
|
||
MT("Operators", | ||
"[meta ^]" | ||
); | ||
|
||
MT("Keywords", | ||
"[keyword logic]", | ||
"[keyword logic] [variable foo]", | ||
"[keyword reg] [variable abc]" | ||
); | ||
|
||
MT("Variables", | ||
"[variable _leading_underscore]", | ||
"[variable _if]", | ||
"[number 12] [variable foo]", | ||
"[variable foo] [number 14]" | ||
); | ||
|
||
MT("Tick defines", | ||
"[def `FOO]", | ||
"[def `foo]", | ||
"[def `FOO_bar]" | ||
); | ||
|
||
MT("System calls", | ||
"[meta $display]", | ||
"[meta $vpi_printf]" | ||
); | ||
|
||
MT("Line comment", "[comment // Hello world]"); | ||
|
||
|
||
|
||
})(); |
Oops, something went wrong.