Commit 11ff829f74fc9004757d853f4eb05cffd2fd0bf0

Golmote 2015-09-05T11:35:00

Tcl: Add operators and punctuation + add examples

diff --git a/components/prism-tcl.js b/components/prism-tcl.js
index 48b53dc..b9e2206 100644
--- a/components/prism-tcl.js
+++ b/components/prism-tcl.js
@@ -37,5 +37,7 @@ Prism.languages.tcl = {
 	'keyword': {
 		pattern: /(^\s*|\[)(after|append|apply|array|auto_(?:execok|import|load|mkindex|qualify|reset)|automkindex_old|bgerror|binary|catch|cd|chan|clock|close|concat|dde|dict|encoding|eof|exec|expr|fblocked|fconfigure|fcopy|file(?:event|name)?|flush|gets|glob|history|http|incr|info|interp|join|lappend|lassign|lindex|linsert|list|llength|load|lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|math(?:func|op)|memory|msgcat|namespace|open|package|parray|pid|pkg_mkIndex|platform|puts|pwd|re_syntax|read|refchan|regexp|registry|regsub|rename|Safe_Base|scan|seek|set|socket|source|split|string|subst|Tcl|tcl(?:_endOfWord|_findLibrary|startOf(?:Next|Previous)Word|wordBreak(?:After|Before)|test|vars)|tell|time|tm|trace|unknown|unload|unset|update|uplevel|vwait)\b/m,
 		lookbehind: true
-	}
+	},
+	'operator': /!=?|\*\*?|==|&&?|\|\|?|<[=<]?|>[=>]?|[-+~\/%?^]|\b(?:eq|ne|in|ni)\b/,
+	'punctuation': /[{}()\[\]]/
 };
diff --git a/components/prism-tcl.min.js b/components/prism-tcl.min.js
index 0b786e4..84a6cfe 100644
--- a/components/prism-tcl.min.js
+++ b/components/prism-tcl.min.js
@@ -1 +1 @@
-Prism.languages.tcl={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*"/,variable:[{pattern:/(\$)(?:::)?(?:[a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/,lookbehind:!0},{pattern:/(\$){[^}]+}/,lookbehind:!0},{pattern:/(^\s*set[ \t]+)(?:::)?(?:[a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/m,lookbehind:!0}],"function":{pattern:/(^\s*proc[ \t]+)[^\s]+/m,lookbehind:!0},builtin:[{pattern:/(^\s*)(?:proc|return|class|error|eval|exit|for|foreach|if|switch|while|break|continue)\b/m,lookbehind:!0},/\b(elseif|else)\b/],scope:{pattern:/(^\s*)(global|upvar|variable)\b/m,lookbehind:!0,alias:"constant"},keyword:{pattern:/(^\s*|\[)(after|append|apply|array|auto_(?:execok|import|load|mkindex|qualify|reset)|automkindex_old|bgerror|binary|catch|cd|chan|clock|close|concat|dde|dict|encoding|eof|exec|expr|fblocked|fconfigure|fcopy|file(?:event|name)?|flush|gets|glob|history|http|incr|info|interp|join|lappend|lassign|lindex|linsert|list|llength|load|lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|math(?:func|op)|memory|msgcat|namespace|open|package|parray|pid|pkg_mkIndex|platform|puts|pwd|re_syntax|read|refchan|regexp|registry|regsub|rename|Safe_Base|scan|seek|set|socket|source|split|string|subst|Tcl|tcl(?:_endOfWord|_findLibrary|startOf(?:Next|Previous)Word|wordBreak(?:After|Before)|test|vars)|tell|time|tm|trace|unknown|unload|unset|update|uplevel|vwait)\b/m,lookbehind:!0}};
\ No newline at end of file
+Prism.languages.tcl={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*"/,variable:[{pattern:/(\$)(?:::)?(?:[a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/,lookbehind:!0},{pattern:/(\$){[^}]+}/,lookbehind:!0},{pattern:/(^\s*set[ \t]+)(?:::)?(?:[a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/m,lookbehind:!0}],"function":{pattern:/(^\s*proc[ \t]+)[^\s]+/m,lookbehind:!0},builtin:[{pattern:/(^\s*)(?:proc|return|class|error|eval|exit|for|foreach|if|switch|while|break|continue)\b/m,lookbehind:!0},/\b(elseif|else)\b/],scope:{pattern:/(^\s*)(global|upvar|variable)\b/m,lookbehind:!0,alias:"constant"},keyword:{pattern:/(^\s*|\[)(after|append|apply|array|auto_(?:execok|import|load|mkindex|qualify|reset)|automkindex_old|bgerror|binary|catch|cd|chan|clock|close|concat|dde|dict|encoding|eof|exec|expr|fblocked|fconfigure|fcopy|file(?:event|name)?|flush|gets|glob|history|http|incr|info|interp|join|lappend|lassign|lindex|linsert|list|llength|load|lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|math(?:func|op)|memory|msgcat|namespace|open|package|parray|pid|pkg_mkIndex|platform|puts|pwd|re_syntax|read|refchan|regexp|registry|regsub|rename|Safe_Base|scan|seek|set|socket|source|split|string|subst|Tcl|tcl(?:_endOfWord|_findLibrary|startOf(?:Next|Previous)Word|wordBreak(?:After|Before)|test|vars)|tell|time|tm|trace|unknown|unload|unset|update|uplevel|vwait)\b/m,lookbehind:!0},operator:/!=?|\*\*?|==|&&?|\|\|?|<[=<]?|>[=>]?|[-+~\/%?^]|\b(?:eq|ne|in|ni)\b/,punctuation:/[{}()\[\]]/};
\ No newline at end of file
diff --git a/examples/prism-tcl.html b/examples/prism-tcl.html
new file mode 100644
index 0000000..9489724
--- /dev/null
+++ b/examples/prism-tcl.html
@@ -0,0 +1,39 @@
+<h1>Tcl</h1>
+<p>To use this language, use the class "language-tcl".</p>
+
+<h2>Comments</h2>
+<pre><code># This is a comment</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"foo \"bar\" baz"
+"foo\
+bar\
+baz"</code></pre>
+
+<h2>Variables</h2>
+<pre><code>$foo
+$foo::bar_42
+$::baz
+${foobar}
+set foo::bar "baz"</code></pre>
+
+<h2>Functions</h2>
+<pre><code>proc foobar {baz} {
+	puts $baz
+}
+
+proc RESTORE/post/:post_id/comment/:comment_id {post_id comment_id} {
+    #| Restore a comment handler
+    comment_restore $comment_id
+    qc::actions redirect [url "/post/$post_id" show_deleted_comment_ids $comment_id]
+}</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+	There are always such cases in every regex-based syntax highlighter.
+	However, Prism dares to be open and honest about them.
+	If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h3>Comment-like substrings</h3>
+<pre><code>"This string is #broken"</code></pre>
\ No newline at end of file
diff --git a/tests/languages/tcl/operator_feature.test b/tests/languages/tcl/operator_feature.test
new file mode 100644
index 0000000..84426a0
--- /dev/null
+++ b/tests/languages/tcl/operator_feature.test
@@ -0,0 +1,45 @@
++
+-
+~
+! !=
+* **
+/
+%
+< <= <<
+> >= >>
+==
+& &&
+| ||
+?
+^
+eq
+ne
+in
+ni
+
+----------------------------------------------------
+
+[
+	["operator", "+"],
+	["operator", "-"],
+	["operator", "~"],
+	["operator", "!"], ["operator", "!="],
+	["operator", "*"], ["operator", "**"],
+	["operator", "/"],
+	["operator", "%"],
+	["operator", "<"], ["operator", "<="], ["operator", "<<"],
+	["operator", ">"], ["operator", ">="], ["operator", ">>"],
+	["operator", "=="],
+	["operator", "&"], ["operator", "&&"],
+	["operator", "|"], ["operator", "||"],
+	["operator", "?"],
+	["operator", "^"],
+	["operator", "eq"],
+	["operator", "ne"],
+	["operator", "in"],
+	["operator", "ni"]
+]
+
+----------------------------------------------------
+
+Checks for all operators.
\ No newline at end of file