Skip to content

Commit

Permalink
Merge branch 'prism-markdown-tcl' of https://github.com/PeterChaplin/…
Browse files Browse the repository at this point in the history
…prism into gh-pages + add tests

Conflicts:
	components.js
  • Loading branch information
Golmote committed Sep 5, 2015
2 parents 942a6ec + c84bd33 commit a3e751a
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ var components = {
"require": "clike",
"owner": "chrischares"
},
"tcl": {
"title": "Tcl",
"owner": "PeterChaplin"
},
"twig": {
"title": "Twig",
"require": "markup",
Expand Down
41 changes: 41 additions & 0 deletions components/prism-tcl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Prism.languages.tcl = {
'comment': {
pattern: /(^|[^\\])#.*/,
lookbehind: true
},
'string': /"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*"/,
'variable': [
{
pattern: /(\$)(?:::)?(?:[a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/,
lookbehind: true
},
{
pattern: /(\$){[^}]+}/,
lookbehind: true
},
{
pattern: /(^\s*set[ \t]+)(?:::)?(?:[a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/m,
lookbehind: true
}
],
'function': {
pattern: /(^\s*proc[ \t]+)[^\s]+/m,
lookbehind: true
},
'builtin': [
{
pattern: /(^\s*)(?:proc|return|class|error|eval|exit|for|foreach|if|switch|while|break|continue)\b/m,
lookbehind: true
},
/\b(elseif|else)\b/
],
'scope': {
pattern: /(^\s*)(global|upvar|variable)\b/m,
lookbehind: true,
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: true
}
};
1 change: 1 addition & 0 deletions components/prism-tcl.min.js

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

35 changes: 35 additions & 0 deletions tests/languages/tcl/builtin_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
proc
return
class
error
eval
exit
for
foreach
if elseif else
switch
while
break
continue

----------------------------------------------------

[
["builtin", "proc"],
["builtin", "return"],
["builtin", "class"],
["builtin", "error"],
["builtin", "eval"],
["builtin", "exit"],
["builtin", "for"],
["builtin", "foreach"],
["builtin", "if"], ["builtin", "elseif"], ["builtin", "else"],
["builtin", "switch"],
["builtin", "while"],
["builtin", "break"],
["builtin", "continue"]
]

----------------------------------------------------

Checks for builtins.
13 changes: 13 additions & 0 deletions tests/languages/tcl/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# foobar

----------------------------------------------------

[
["comment", "#"],
["comment", "# foobar"]
]

----------------------------------------------------

Checks for comments.
15 changes: 15 additions & 0 deletions tests/languages/tcl/function_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
proc foo
proc Foobar
proc foo_bar_42

----------------------------------------------------

[
["builtin", "proc"], ["function", "foo"],
["builtin", "proc"], ["function", "Foobar"],
["builtin", "proc"], ["function", "foo_bar_42"]
]

----------------------------------------------------

Checks for functions.
213 changes: 213 additions & 0 deletions tests/languages/tcl/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
after
append
apply
array
auto_execok
auto_import
auto_load
auto_mkindex
auto_qualify
auto_reset
automkindex_old
bgerror
binary
catch
cd
chan
clock
close
concat
dde
dict
encoding
eof
exec
expr
fblocked
fconfigure
fcopy
file
fileevent
filename
flush
gets
glob
history
http
incr
info
interp
join
lappend
lassign
lindex
linsert
list
llength
load
lrange
lrepeat
lreplace
lreverse
lsearch
lset
lsort
mathfunc
mathop
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
tcl_findLibrary
tclstartOfNextWord
tclstartOfPreviousWord
tclwordBreakAfter
tclwordBreakBefore
tcltest
tclvars
tell
time
tm
trace
unknown
unload
unset
update
uplevel
vwait

----------------------------------------------------

[
["keyword", "after"],
["keyword", "append"],
["keyword", "apply"],
["keyword", "array"],
["keyword", "auto_execok"],
["keyword", "auto_import"],
["keyword", "auto_load"],
["keyword", "auto_mkindex"],
["keyword", "auto_qualify"],
["keyword", "auto_reset"],
["keyword", "automkindex_old"],
["keyword", "bgerror"],
["keyword", "binary"],
["keyword", "catch"],
["keyword", "cd"],
["keyword", "chan"],
["keyword", "clock"],
["keyword", "close"],
["keyword", "concat"],
["keyword", "dde"],
["keyword", "dict"],
["keyword", "encoding"],
["keyword", "eof"],
["keyword", "exec"],
["keyword", "expr"],
["keyword", "fblocked"],
["keyword", "fconfigure"],
["keyword", "fcopy"],
["keyword", "file"],
["keyword", "fileevent"],
["keyword", "filename"],
["keyword", "flush"],
["keyword", "gets"],
["keyword", "glob"],
["keyword", "history"],
["keyword", "http"],
["keyword", "incr"],
["keyword", "info"],
["keyword", "interp"],
["keyword", "join"],
["keyword", "lappend"],
["keyword", "lassign"],
["keyword", "lindex"],
["keyword", "linsert"],
["keyword", "list"],
["keyword", "llength"],
["keyword", "load"],
["keyword", "lrange"],
["keyword", "lrepeat"],
["keyword", "lreplace"],
["keyword", "lreverse"],
["keyword", "lsearch"],
["keyword", "lset"],
["keyword", "lsort"],
["keyword", "mathfunc"],
["keyword", "mathop"],
["keyword", "memory"],
["keyword", "msgcat"],
["keyword", "namespace"],
["keyword", "open"],
["keyword", "package"],
["keyword", "parray"],
["keyword", "pid"],
["keyword", "pkg_mkIndex"],
["keyword", "platform"],
["keyword", "puts"],
["keyword", "pwd"],
["keyword", "re_syntax"],
["keyword", "read"],
["keyword", "refchan"],
["keyword", "regexp"],
["keyword", "registry"],
["keyword", "regsub"],
["keyword", "rename"],
["keyword", "Safe_Base"],
["keyword", "scan"],
["keyword", "seek"],
["keyword", "set"],
["keyword", "socket"],
["keyword", "source"],
["keyword", "split"],
["keyword", "string"],
["keyword", "subst"],
["keyword", "Tcl"],
["keyword", "tcl_endOfWord"],
["keyword", "tcl_findLibrary"],
["keyword", "tclstartOfNextWord"],
["keyword", "tclstartOfPreviousWord"],
["keyword", "tclwordBreakAfter"],
["keyword", "tclwordBreakBefore"],
["keyword", "tcltest"],
["keyword", "tclvars"],
["keyword", "tell"],
["keyword", "time"],
["keyword", "tm"],
["keyword", "trace"],
["keyword", "unknown"],
["keyword", "unload"],
["keyword", "unset"],
["keyword", "update"],
["keyword", "uplevel"],
["keyword", "vwait"]
]

----------------------------------------------------

Checks for keywords.
15 changes: 15 additions & 0 deletions tests/languages/tcl/scope_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
global
upvar
variable

----------------------------------------------------

[
["scope", "global"],
["scope", "upvar"],
["scope", "variable"]
]

----------------------------------------------------

Checks for scopes.
16 changes: 16 additions & 0 deletions tests/languages/tcl/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
""
"fo\"obar"
"fo\"o\
bar"

----------------------------------------------------

[
["string", "\"\""],
["string", "\"fo\\\"obar\""],
["string", "\"fo\\\"o\\\r\nbar\""]
]

----------------------------------------------------

Checks for strings.
Loading

0 comments on commit a3e751a

Please sign in to comment.