Skip to content

Commit

Permalink
Tcl: Add operators and punctuation + add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Sep 5, 2015
1 parent a3e751a commit 11ff829
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/prism-tcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': /[{}()\[\]]/
};
2 changes: 1 addition & 1 deletion components/prism-tcl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions examples/prism-tcl.html
Original file line number Diff line number Diff line change
@@ -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>
45 changes: 45 additions & 0 deletions tests/languages/tcl/operator_feature.test
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 11ff829

Please sign in to comment.