/usr/lib/nodejs/highlight/coffeescript.js is in node-highlight 7.4+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | module.exports = function(hljs) {
var KEYWORDS = {
keyword:
// JS keywords
'in if for while finally new do return else break catch instanceof throw try this ' +
'switch continue typeof delete debugger super ' +
// Coffee keywords
'then unless until loop of by when and or is isnt not',
literal:
// JS literals
'true false null undefined ' +
// Coffee literals
'yes no on off',
reserved:
'case default function var void with const let enum export import native ' +
'__hasProp __extends __slice __bind __indexOf',
built_in:
'npm require console print module exports global window document'
};
var JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
var TITLE = {className: 'title', begin: JS_IDENT_RE};
var SUBST = {
className: 'subst',
begin: '#\\{', end: '}',
keywords: KEYWORDS,
};
var EXPRESSIONS = [
// Numbers
hljs.BINARY_NUMBER_MODE,
hljs.inherit(hljs.C_NUMBER_MODE, {starts: {end: '(\\s*/)?', relevance: 0}}), // a number tries to eat the following slash to prevent treating it as a regexp
// Strings
{
className: 'string',
begin: '\'\'\'', end: '\'\'\'',
contains: [hljs.BACKSLASH_ESCAPE]
},
{
className: 'string',
begin: '\'', end: '\'',
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0
},
{
className: 'string',
begin: '"""', end: '"""',
contains: [hljs.BACKSLASH_ESCAPE, SUBST]
},
{
className: 'string',
begin: '"', end: '"',
contains: [hljs.BACKSLASH_ESCAPE, SUBST],
relevance: 0
},
// RegExps
{
className: 'regexp',
begin: '///', end: '///',
contains: [hljs.HASH_COMMENT_MODE]
},
{
className: 'regexp', begin: '//[gim]*',
relevance: 0
},
{
className: 'regexp',
begin: '/\\S(\\\\.|[^\\n])*?/[gim]*(?=\\s|\\W|$)' // \S is required to parse x / 2 / 3 as two divisions
},
{
className: 'property',
begin: '@' + JS_IDENT_RE
},
{
begin: '`', end: '`',
excludeBegin: true, excludeEnd: true,
subLanguage: 'javascript'
}
];
SUBST.contains = EXPRESSIONS;
return {
keywords: KEYWORDS,
contains: EXPRESSIONS.concat([
{
className: 'comment',
begin: '###', end: '###'
},
hljs.HASH_COMMENT_MODE,
{
className: 'function',
begin: '(' + JS_IDENT_RE + '\\s*=\\s*)?(\\(.*\\))?\\s*[-=]>', end: '[-=]>',
returnBegin: true,
contains: [
TITLE,
{
className: 'params',
begin: '\\(', returnBegin: true,
/* We need another contained nameless mode to not have every nested
pair of parens to be called "params" */
contains: [{
begin: /\(/, end: /\)/,
keywords: KEYWORDS,
contains: ['self'].concat(EXPRESSIONS)
}]
}
]
},
{
className: 'class',
beginWithKeyword: true, keywords: 'class',
end: '$',
illegal: '[:\\[\\]]',
contains: [
{
beginWithKeyword: true, keywords: 'extends',
endsWithParent: true,
illegal: ':',
contains: [TITLE]
},
TITLE
]
},
{
className: 'attribute',
begin: JS_IDENT_RE + ':', end: ':',
returnBegin: true, excludeEnd: true
}
])
};
};
|