forked from forgejo/forgejo
* Cleaning up public/ and documenting js/css libs. This commit mostly addresses #1484 by moving vendor'ed plugins into a vendor/ directory and documenting their upstream source and license in vendor/librejs.html. This also proves gitea is using only open source js/css libraries which helps toward reaching #1524. * Removing unused css file. The version of this file in use is located at: vendor/plugins/highlight/github.css * Cleaned up librejs.html and added javascript header A SafeJS function was added to templates/helper.go to allow keeping comments inside of javascript. A javascript comment was added in the header of templates/base/head.tmpl to mark all non-inline source as free. The librejs.html file was updated to meet the current librejs spec. I have now verified that the librejs plugin detects most of the scripts included in gitea and suspect the non-free detections are the result of a bug in the plugin. I believe this commit is enough to meet the C0.0 requirement of #1534. * Updating SafeJS function per lint suggestion * Added VERSIONS file, per request
This commit is contained in:
parent
64b7068846
commit
a915a09e4f
1339 changed files with 813 additions and 126 deletions
459
public/vendor/plugins/codemirror/mode/livescript/index.html
vendored
Normal file
459
public/vendor/plugins/codemirror/mode/livescript/index.html
vendored
Normal file
|
@ -0,0 +1,459 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: LiveScript mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/solarized.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="livescript.js"></script>
|
||||
<style>.CodeMirror {font-size: 80%;border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><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/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">LiveScript</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>LiveScript mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
# LiveScript mode for CodeMirror
|
||||
# The following script, prelude.ls, is used to
|
||||
# demonstrate LiveScript mode for CodeMirror.
|
||||
# https://github.com/gkz/prelude-ls
|
||||
|
||||
export objToFunc = objToFunc = (obj) ->
|
||||
(key) -> obj[key]
|
||||
|
||||
export each = (f, xs) -->
|
||||
if typeof! xs is \Object
|
||||
for , x of xs then f x
|
||||
else
|
||||
for x in xs then f x
|
||||
xs
|
||||
|
||||
export map = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
type = typeof! xs
|
||||
if type is \Object
|
||||
{[key, f x] for key, x of xs}
|
||||
else
|
||||
result = [f x for x in xs]
|
||||
if type is \String then result * '' else result
|
||||
|
||||
export filter = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
type = typeof! xs
|
||||
if type is \Object
|
||||
{[key, x] for key, x of xs when f x}
|
||||
else
|
||||
result = [x for x in xs when f x]
|
||||
if type is \String then result * '' else result
|
||||
|
||||
export reject = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
type = typeof! xs
|
||||
if type is \Object
|
||||
{[key, x] for key, x of xs when not f x}
|
||||
else
|
||||
result = [x for x in xs when not f x]
|
||||
if type is \String then result * '' else result
|
||||
|
||||
export partition = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
type = typeof! xs
|
||||
if type is \Object
|
||||
passed = {}
|
||||
failed = {}
|
||||
for key, x of xs
|
||||
(if f x then passed else failed)[key] = x
|
||||
else
|
||||
passed = []
|
||||
failed = []
|
||||
for x in xs
|
||||
(if f x then passed else failed)push x
|
||||
if type is \String
|
||||
passed *= ''
|
||||
failed *= ''
|
||||
[passed, failed]
|
||||
|
||||
export find = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
if typeof! xs is \Object
|
||||
for , x of xs when f x then return x
|
||||
else
|
||||
for x in xs when f x then return x
|
||||
void
|
||||
|
||||
export head = export first = (xs) ->
|
||||
return void if not xs.length
|
||||
xs.0
|
||||
|
||||
export tail = (xs) ->
|
||||
return void if not xs.length
|
||||
xs.slice 1
|
||||
|
||||
export last = (xs) ->
|
||||
return void if not xs.length
|
||||
xs[*-1]
|
||||
|
||||
export initial = (xs) ->
|
||||
return void if not xs.length
|
||||
xs.slice 0 xs.length - 1
|
||||
|
||||
export empty = (xs) ->
|
||||
if typeof! xs is \Object
|
||||
for x of xs then return false
|
||||
return yes
|
||||
not xs.length
|
||||
|
||||
export values = (obj) ->
|
||||
[x for , x of obj]
|
||||
|
||||
export keys = (obj) ->
|
||||
[x for x of obj]
|
||||
|
||||
export len = (xs) ->
|
||||
xs = values xs if typeof! xs is \Object
|
||||
xs.length
|
||||
|
||||
export cons = (x, xs) -->
|
||||
if typeof! xs is \String then x + xs else [x] ++ xs
|
||||
|
||||
export append = (xs, ys) -->
|
||||
if typeof! ys is \String then xs + ys else xs ++ ys
|
||||
|
||||
export join = (sep, xs) -->
|
||||
xs = values xs if typeof! xs is \Object
|
||||
xs.join sep
|
||||
|
||||
export reverse = (xs) ->
|
||||
if typeof! xs is \String
|
||||
then (xs / '')reverse! * ''
|
||||
else xs.slice!reverse!
|
||||
|
||||
export fold = export foldl = (f, memo, xs) -->
|
||||
if typeof! xs is \Object
|
||||
for , x of xs then memo = f memo, x
|
||||
else
|
||||
for x in xs then memo = f memo, x
|
||||
memo
|
||||
|
||||
export fold1 = export foldl1 = (f, xs) --> fold f, xs.0, xs.slice 1
|
||||
|
||||
export foldr = (f, memo, xs) --> fold f, memo, xs.slice!reverse!
|
||||
|
||||
export foldr1 = (f, xs) -->
|
||||
xs.=slice!reverse!
|
||||
fold f, xs.0, xs.slice 1
|
||||
|
||||
export unfoldr = export unfold = (f, b) -->
|
||||
if (f b)?
|
||||
[that.0] ++ unfoldr f, that.1
|
||||
else
|
||||
[]
|
||||
|
||||
export andList = (xs) ->
|
||||
for x in xs when not x
|
||||
return false
|
||||
true
|
||||
|
||||
export orList = (xs) ->
|
||||
for x in xs when x
|
||||
return true
|
||||
false
|
||||
|
||||
export any = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
for x in xs when f x
|
||||
return yes
|
||||
no
|
||||
|
||||
export all = (f, xs) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
for x in xs when not f x
|
||||
return no
|
||||
yes
|
||||
|
||||
export unique = (xs) ->
|
||||
result = []
|
||||
if typeof! xs is \Object
|
||||
for , x of xs when x not in result then result.push x
|
||||
else
|
||||
for x in xs when x not in result then result.push x
|
||||
if typeof! xs is \String then result * '' else result
|
||||
|
||||
export sort = (xs) ->
|
||||
xs.concat!sort (x, y) ->
|
||||
| x > y => 1
|
||||
| x < y => -1
|
||||
| _ => 0
|
||||
|
||||
export sortBy = (f, xs) -->
|
||||
return [] unless xs.length
|
||||
xs.concat!sort f
|
||||
|
||||
export compare = (f, x, y) -->
|
||||
| (f x) > (f y) => 1
|
||||
| (f x) < (f y) => -1
|
||||
| otherwise => 0
|
||||
|
||||
export sum = (xs) ->
|
||||
result = 0
|
||||
if typeof! xs is \Object
|
||||
for , x of xs then result += x
|
||||
else
|
||||
for x in xs then result += x
|
||||
result
|
||||
|
||||
export product = (xs) ->
|
||||
result = 1
|
||||
if typeof! xs is \Object
|
||||
for , x of xs then result *= x
|
||||
else
|
||||
for x in xs then result *= x
|
||||
result
|
||||
|
||||
export mean = export average = (xs) -> (sum xs) / len xs
|
||||
|
||||
export concat = (xss) -> fold append, [], xss
|
||||
|
||||
export concatMap = (f, xs) --> fold ((memo, x) -> append memo, f x), [], xs
|
||||
|
||||
export listToObj = (xs) ->
|
||||
{[x.0, x.1] for x in xs}
|
||||
|
||||
export maximum = (xs) -> fold1 (>?), xs
|
||||
|
||||
export minimum = (xs) -> fold1 (<?), xs
|
||||
|
||||
export scan = export scanl = (f, memo, xs) -->
|
||||
last = memo
|
||||
if typeof! xs is \Object
|
||||
then [memo] ++ [last = f last, x for , x of xs]
|
||||
else [memo] ++ [last = f last, x for x in xs]
|
||||
|
||||
export scan1 = export scanl1 = (f, xs) --> scan f, xs.0, xs.slice 1
|
||||
|
||||
export scanr = (f, memo, xs) -->
|
||||
xs.=slice!reverse!
|
||||
scan f, memo, xs .reverse!
|
||||
|
||||
export scanr1 = (f, xs) -->
|
||||
xs.=slice!reverse!
|
||||
scan f, xs.0, xs.slice 1 .reverse!
|
||||
|
||||
export replicate = (n, x) -->
|
||||
result = []
|
||||
i = 0
|
||||
while i < n, ++i then result.push x
|
||||
result
|
||||
|
||||
export take = (n, xs) -->
|
||||
| n <= 0
|
||||
if typeof! xs is \String then '' else []
|
||||
| not xs.length => xs
|
||||
| otherwise => xs.slice 0, n
|
||||
|
||||
export drop = (n, xs) -->
|
||||
| n <= 0 => xs
|
||||
| not xs.length => xs
|
||||
| otherwise => xs.slice n
|
||||
|
||||
export splitAt = (n, xs) --> [(take n, xs), (drop n, xs)]
|
||||
|
||||
export takeWhile = (p, xs) -->
|
||||
return xs if not xs.length
|
||||
p = objToFunc p if typeof! p isnt \Function
|
||||
result = []
|
||||
for x in xs
|
||||
break if not p x
|
||||
result.push x
|
||||
if typeof! xs is \String then result * '' else result
|
||||
|
||||
export dropWhile = (p, xs) -->
|
||||
return xs if not xs.length
|
||||
p = objToFunc p if typeof! p isnt \Function
|
||||
i = 0
|
||||
for x in xs
|
||||
break if not p x
|
||||
++i
|
||||
drop i, xs
|
||||
|
||||
export span = (p, xs) --> [(takeWhile p, xs), (dropWhile p, xs)]
|
||||
|
||||
export breakIt = (p, xs) --> span (not) << p, xs
|
||||
|
||||
export zip = (xs, ys) -->
|
||||
result = []
|
||||
for zs, i in [xs, ys]
|
||||
for z, j in zs
|
||||
result.push [] if i is 0
|
||||
result[j]?push z
|
||||
result
|
||||
|
||||
export zipWith = (f,xs, ys) -->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
if not xs.length or not ys.length
|
||||
[]
|
||||
else
|
||||
[f.apply this, zs for zs in zip.call this, xs, ys]
|
||||
|
||||
export zipAll = (...xss) ->
|
||||
result = []
|
||||
for xs, i in xss
|
||||
for x, j in xs
|
||||
result.push [] if i is 0
|
||||
result[j]?push x
|
||||
result
|
||||
|
||||
export zipAllWith = (f, ...xss) ->
|
||||
f = objToFunc f if typeof! f isnt \Function
|
||||
if not xss.0.length or not xss.1.length
|
||||
[]
|
||||
else
|
||||
[f.apply this, xs for xs in zipAll.apply this, xss]
|
||||
|
||||
export compose = (...funcs) ->
|
||||
->
|
||||
args = arguments
|
||||
for f in funcs
|
||||
args = [f.apply this, args]
|
||||
args.0
|
||||
|
||||
export curry = (f) ->
|
||||
curry$ f # using util method curry$ from livescript
|
||||
|
||||
export id = (x) -> x
|
||||
|
||||
export flip = (f, x, y) --> f y, x
|
||||
|
||||
export fix = (f) ->
|
||||
( (g, x) -> -> f(g g) ...arguments ) do
|
||||
(g, x) -> -> f(g g) ...arguments
|
||||
|
||||
export lines = (str) ->
|
||||
return [] if not str.length
|
||||
str / \\n
|
||||
|
||||
export unlines = (strs) -> strs * \\n
|
||||
|
||||
export words = (str) ->
|
||||
return [] if not str.length
|
||||
str / /[ ]+/
|
||||
|
||||
export unwords = (strs) -> strs * ' '
|
||||
|
||||
export max = (>?)
|
||||
|
||||
export min = (<?)
|
||||
|
||||
export negate = (x) -> -x
|
||||
|
||||
export abs = Math.abs
|
||||
|
||||
export signum = (x) ->
|
||||
| x < 0 => -1
|
||||
| x > 0 => 1
|
||||
| otherwise => 0
|
||||
|
||||
export quot = (x, y) --> ~~(x / y)
|
||||
|
||||
export rem = (%)
|
||||
|
||||
export div = (x, y) --> Math.floor x / y
|
||||
|
||||
export mod = (%%)
|
||||
|
||||
export recip = (1 /)
|
||||
|
||||
export pi = Math.PI
|
||||
|
||||
export tau = pi * 2
|
||||
|
||||
export exp = Math.exp
|
||||
|
||||
export sqrt = Math.sqrt
|
||||
|
||||
# changed from log as log is a
|
||||
# common function for logging things
|
||||
export ln = Math.log
|
||||
|
||||
export pow = (^)
|
||||
|
||||
export sin = Math.sin
|
||||
|
||||
export tan = Math.tan
|
||||
|
||||
export cos = Math.cos
|
||||
|
||||
export asin = Math.asin
|
||||
|
||||
export acos = Math.acos
|
||||
|
||||
export atan = Math.atan
|
||||
|
||||
export atan2 = (x, y) --> Math.atan2 x, y
|
||||
|
||||
# sinh
|
||||
# tanh
|
||||
# cosh
|
||||
# asinh
|
||||
# atanh
|
||||
# acosh
|
||||
|
||||
export truncate = (x) -> ~~x
|
||||
|
||||
export round = Math.round
|
||||
|
||||
export ceiling = Math.ceil
|
||||
|
||||
export floor = Math.floor
|
||||
|
||||
export isItNaN = (x) -> x isnt x
|
||||
|
||||
export even = (x) -> x % 2 == 0
|
||||
|
||||
export odd = (x) -> x % 2 != 0
|
||||
|
||||
export gcd = (x, y) -->
|
||||
x = Math.abs x
|
||||
y = Math.abs y
|
||||
until y is 0
|
||||
z = x % y
|
||||
x = y
|
||||
y = z
|
||||
x
|
||||
|
||||
export lcm = (x, y) -->
|
||||
Math.abs Math.floor (x / (gcd x, y) * y)
|
||||
|
||||
# meta
|
||||
export installPrelude = !(target) ->
|
||||
unless target.prelude?isInstalled
|
||||
target <<< out$ # using out$ generated by livescript
|
||||
target <<< target.prelude.isInstalled = true
|
||||
|
||||
export prelude = out$
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
theme: "solarized light",
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-livescript</code>.</p>
|
||||
|
||||
<p>The LiveScript mode was written by Kenneth Bentley.</p>
|
||||
|
||||
</article>
|
280
public/vendor/plugins/codemirror/mode/livescript/livescript.js
vendored
Normal file
280
public/vendor/plugins/codemirror/mode/livescript/livescript.js
vendored
Normal file
|
@ -0,0 +1,280 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/**
|
||||
* Link to the project's GitHub page:
|
||||
* https://github.com/duralog/CodeMirror
|
||||
*/
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode('livescript', function(){
|
||||
var tokenBase = function(stream, state) {
|
||||
var next_rule = state.next || "start";
|
||||
if (next_rule) {
|
||||
state.next = state.next;
|
||||
var nr = Rules[next_rule];
|
||||
if (nr.splice) {
|
||||
for (var i$ = 0; i$ < nr.length; ++i$) {
|
||||
var r = nr[i$];
|
||||
if (r.regex && stream.match(r.regex)) {
|
||||
state.next = r.next || state.next;
|
||||
return r.token;
|
||||
}
|
||||
}
|
||||
stream.next();
|
||||
return 'error';
|
||||
}
|
||||
if (stream.match(r = Rules[next_rule])) {
|
||||
if (r.regex && stream.match(r.regex)) {
|
||||
state.next = r.next;
|
||||
return r.token;
|
||||
} else {
|
||||
stream.next();
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
}
|
||||
stream.next();
|
||||
return 'error';
|
||||
};
|
||||
var external = {
|
||||
startState: function(){
|
||||
return {
|
||||
next: 'start',
|
||||
lastToken: null
|
||||
};
|
||||
},
|
||||
token: function(stream, state){
|
||||
while (stream.pos == stream.start)
|
||||
var style = tokenBase(stream, state);
|
||||
state.lastToken = {
|
||||
style: style,
|
||||
indent: stream.indentation(),
|
||||
content: stream.current()
|
||||
};
|
||||
return style.replace(/\./g, ' ');
|
||||
},
|
||||
indent: function(state){
|
||||
var indentation = state.lastToken.indent;
|
||||
if (state.lastToken.content.match(indenter)) {
|
||||
indentation += 2;
|
||||
}
|
||||
return indentation;
|
||||
}
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
var identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
|
||||
var indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
|
||||
var keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
|
||||
var stringfill = {
|
||||
token: 'string',
|
||||
regex: '.+'
|
||||
};
|
||||
var Rules = {
|
||||
start: [
|
||||
{
|
||||
token: 'comment.doc',
|
||||
regex: '/\\*',
|
||||
next: 'comment'
|
||||
}, {
|
||||
token: 'comment',
|
||||
regex: '#.*'
|
||||
}, {
|
||||
token: 'keyword',
|
||||
regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
|
||||
}, {
|
||||
token: 'constant.language',
|
||||
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
|
||||
}, {
|
||||
token: 'invalid.illegal',
|
||||
regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
|
||||
}, {
|
||||
token: 'language.support.class',
|
||||
regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
|
||||
}, {
|
||||
token: 'language.support.function',
|
||||
regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
|
||||
}, {
|
||||
token: 'variable.language',
|
||||
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
|
||||
}, {
|
||||
token: 'identifier',
|
||||
regex: identifier + '\\s*:(?![:=])'
|
||||
}, {
|
||||
token: 'variable',
|
||||
regex: identifier
|
||||
}, {
|
||||
token: 'keyword.operator',
|
||||
regex: '(?:\\.{3}|\\s+\\?)'
|
||||
}, {
|
||||
token: 'keyword.variable',
|
||||
regex: '(?:@+|::|\\.\\.)',
|
||||
next: 'key'
|
||||
}, {
|
||||
token: 'keyword.operator',
|
||||
regex: '\\.\\s*',
|
||||
next: 'key'
|
||||
}, {
|
||||
token: 'string',
|
||||
regex: '\\\\\\S[^\\s,;)}\\]]*'
|
||||
}, {
|
||||
token: 'string.doc',
|
||||
regex: '\'\'\'',
|
||||
next: 'qdoc'
|
||||
}, {
|
||||
token: 'string.doc',
|
||||
regex: '"""',
|
||||
next: 'qqdoc'
|
||||
}, {
|
||||
token: 'string',
|
||||
regex: '\'',
|
||||
next: 'qstring'
|
||||
}, {
|
||||
token: 'string',
|
||||
regex: '"',
|
||||
next: 'qqstring'
|
||||
}, {
|
||||
token: 'string',
|
||||
regex: '`',
|
||||
next: 'js'
|
||||
}, {
|
||||
token: 'string',
|
||||
regex: '<\\[',
|
||||
next: 'words'
|
||||
}, {
|
||||
token: 'string.regex',
|
||||
regex: '//',
|
||||
next: 'heregex'
|
||||
}, {
|
||||
token: 'string.regex',
|
||||
regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
|
||||
next: 'key'
|
||||
}, {
|
||||
token: 'constant.numeric',
|
||||
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
|
||||
}, {
|
||||
token: 'lparen',
|
||||
regex: '[({[]'
|
||||
}, {
|
||||
token: 'rparen',
|
||||
regex: '[)}\\]]',
|
||||
next: 'key'
|
||||
}, {
|
||||
token: 'keyword.operator',
|
||||
regex: '\\S+'
|
||||
}, {
|
||||
token: 'text',
|
||||
regex: '\\s+'
|
||||
}
|
||||
],
|
||||
heregex: [
|
||||
{
|
||||
token: 'string.regex',
|
||||
regex: '.*?//[gimy$?]{0,4}',
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'string.regex',
|
||||
regex: '\\s*#{'
|
||||
}, {
|
||||
token: 'comment.regex',
|
||||
regex: '\\s+(?:#.*)?'
|
||||
}, {
|
||||
token: 'string.regex',
|
||||
regex: '\\S+'
|
||||
}
|
||||
],
|
||||
key: [
|
||||
{
|
||||
token: 'keyword.operator',
|
||||
regex: '[.?@!]+'
|
||||
}, {
|
||||
token: 'identifier',
|
||||
regex: identifier,
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'text',
|
||||
regex: '',
|
||||
next: 'start'
|
||||
}
|
||||
],
|
||||
comment: [
|
||||
{
|
||||
token: 'comment.doc',
|
||||
regex: '.*?\\*/',
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'comment.doc',
|
||||
regex: '.+'
|
||||
}
|
||||
],
|
||||
qdoc: [
|
||||
{
|
||||
token: 'string',
|
||||
regex: ".*?'''",
|
||||
next: 'key'
|
||||
}, stringfill
|
||||
],
|
||||
qqdoc: [
|
||||
{
|
||||
token: 'string',
|
||||
regex: '.*?"""',
|
||||
next: 'key'
|
||||
}, stringfill
|
||||
],
|
||||
qstring: [
|
||||
{
|
||||
token: 'string',
|
||||
regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
|
||||
next: 'key'
|
||||
}, stringfill
|
||||
],
|
||||
qqstring: [
|
||||
{
|
||||
token: 'string',
|
||||
regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
|
||||
next: 'key'
|
||||
}, stringfill
|
||||
],
|
||||
js: [
|
||||
{
|
||||
token: 'string',
|
||||
regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
|
||||
next: 'key'
|
||||
}, stringfill
|
||||
],
|
||||
words: [
|
||||
{
|
||||
token: 'string',
|
||||
regex: '.*?\\]>',
|
||||
next: 'key'
|
||||
}, stringfill
|
||||
]
|
||||
};
|
||||
for (var idx in Rules) {
|
||||
var r = Rules[idx];
|
||||
if (r.splice) {
|
||||
for (var i = 0, len = r.length; i < len; ++i) {
|
||||
var rr = r[i];
|
||||
if (typeof rr.regex === 'string') {
|
||||
Rules[idx][i].regex = new RegExp('^' + rr.regex);
|
||||
}
|
||||
}
|
||||
} else if (typeof rr.regex === 'string') {
|
||||
Rules[idx].regex = new RegExp('^' + r.regex);
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME('text/x-livescript', 'livescript');
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue