Skip to content

Commit 87d7cce

Browse files
committed
Added new languages.
1 parent 75f24bd commit 87d7cce

File tree

19 files changed

+871
-19
lines changed

19 files changed

+871
-19
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Language: Apache
3+
Author: Ruslan Keba <[email protected]>
4+
Contributors: Ivan Sagalaev <[email protected]>
5+
Website: http://rukeba.com/
6+
Description: language definition for Apache configuration files (httpd.conf & .htaccess)
7+
Category: common, config
8+
*/
9+
10+
function(hljs) {
11+
var NUMBER = {className: 'number', begin: '[\\$%]\\d+'};
12+
return {
13+
aliases: ['apacheconf'],
14+
case_insensitive: true,
15+
contains: [
16+
hljs.HASH_COMMENT_MODE,
17+
{className: 'section', begin: '</?', end: '>'},
18+
{
19+
className: 'attribute',
20+
begin: /\w+/,
21+
relevance: 0,
22+
// keywords aren’t needed for highlighting per se, they only boost relevance
23+
// for a very generally defined mode (starts with a word, ends with line-end
24+
keywords: {
25+
nomarkup:
26+
'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
27+
'sethandler errordocument loadmodule options header listen serverroot ' +
28+
'servername'
29+
},
30+
starts: {
31+
end: /$/,
32+
relevance: 0,
33+
keywords: {
34+
literal: 'on off all'
35+
},
36+
contains: [
37+
{
38+
className: 'meta',
39+
begin: '\\s\\[', end: '\\]$'
40+
},
41+
{
42+
className: 'variable',
43+
begin: '[\\$%]\\{', end: '\\}',
44+
contains: ['self', NUMBER]
45+
},
46+
NUMBER,
47+
hljs.QUOTE_STRING_MODE
48+
]
49+
}
50+
}
51+
],
52+
illegal: /\S/
53+
};
54+
}

dev/highlightjs/languages/cpp.js

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/*
2+
Language: C++
3+
Author: Ivan Sagalaev <[email protected]>
4+
Contributors: Evgeny Stepanischev <[email protected]>, Zaven Muradyan <[email protected]>, Roel Deckers <[email protected]>, Sam Wu <[email protected]>, Jordi Petit <[email protected]>, Pieter Vantorre <[email protected]>, Google Inc. (David Benjamin) <[email protected]>
5+
Category: common, system
6+
*/
7+
8+
function(hljs) {
9+
var CPP_PRIMITIVE_TYPES = {
10+
className: 'keyword',
11+
begin: '\\b[a-z\\d_]*_t\\b'
12+
};
13+
14+
var STRINGS = {
15+
className: 'string',
16+
variants: [
17+
{
18+
begin: '(u8?|U|L)?"', end: '"',
19+
illegal: '\\n',
20+
contains: [hljs.BACKSLASH_ESCAPE]
21+
},
22+
{ begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\((?:.|\n)*?\)\1"/ },
23+
{
24+
begin: '\'\\\\?.', end: '\'',
25+
illegal: '.'
26+
}
27+
]
28+
};
29+
30+
var NUMBERS = {
31+
className: 'number',
32+
variants: [
33+
{ begin: '\\b(0b[01\']+)' },
34+
{ begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' },
35+
{ begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' }
36+
],
37+
relevance: 0
38+
};
39+
40+
var PREPROCESSOR = {
41+
className: 'meta',
42+
begin: /#\s*[a-z]+\b/, end: /$/,
43+
keywords: {
44+
'meta-keyword':
45+
'if else elif endif define undef warning error line ' +
46+
'pragma ifdef ifndef include'
47+
},
48+
contains: [
49+
{
50+
begin: /\\\n/, relevance: 0
51+
},
52+
hljs.inherit(STRINGS, {className: 'meta-string'}),
53+
{
54+
className: 'meta-string',
55+
begin: /<[^\n>]*>/, end: /$/,
56+
illegal: '\\n',
57+
},
58+
hljs.C_LINE_COMMENT_MODE,
59+
hljs.C_BLOCK_COMMENT_MODE
60+
]
61+
};
62+
63+
var FUNCTION_TITLE = hljs.IDENT_RE + '\\s*\\(';
64+
65+
var CPP_KEYWORDS = {
66+
keyword: 'int float while private char catch import module export virtual operator sizeof ' +
67+
'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' +
68+
'unsigned long volatile static protected bool template mutable if public friend ' +
69+
'do goto auto void enum else break extern using asm case typeid ' +
70+
'short reinterpret_cast|10 default double register explicit signed typename try this ' +
71+
'switch continue inline delete alignof constexpr decltype ' +
72+
'noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary ' +
73+
'atomic_bool atomic_char atomic_schar ' +
74+
'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
75+
'atomic_ullong new throw return ' +
76+
'and or not',
77+
built_in: 'std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
78+
'auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set ' +
79+
'unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos ' +
80+
'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
81+
'fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
82+
'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
83+
'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
84+
'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
85+
'vfprintf vprintf vsprintf endl initializer_list unique_ptr',
86+
literal: 'true false nullptr NULL'
87+
};
88+
89+
var EXPRESSION_CONTAINS = [
90+
CPP_PRIMITIVE_TYPES,
91+
hljs.C_LINE_COMMENT_MODE,
92+
hljs.C_BLOCK_COMMENT_MODE,
93+
NUMBERS,
94+
STRINGS
95+
];
96+
97+
return {
98+
aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp', 'hh', 'hxx', 'cxx'],
99+
keywords: CPP_KEYWORDS,
100+
illegal: '</',
101+
contains: EXPRESSION_CONTAINS.concat([
102+
PREPROCESSOR,
103+
{
104+
begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>',
105+
keywords: CPP_KEYWORDS,
106+
contains: ['self', CPP_PRIMITIVE_TYPES]
107+
},
108+
{
109+
begin: hljs.IDENT_RE + '::',
110+
keywords: CPP_KEYWORDS
111+
},
112+
{
113+
// This mode covers expression context where we can't expect a function
114+
// definition and shouldn't highlight anything that looks like one:
115+
// `return some()`, `else if()`, `(x*sum(1, 2))`
116+
variants: [
117+
{begin: /=/, end: /;/},
118+
{begin: /\(/, end: /\)/},
119+
{beginKeywords: 'new throw return else', end: /;/}
120+
],
121+
keywords: CPP_KEYWORDS,
122+
contains: EXPRESSION_CONTAINS.concat([
123+
{
124+
begin: /\(/, end: /\)/,
125+
keywords: CPP_KEYWORDS,
126+
contains: EXPRESSION_CONTAINS.concat(['self']),
127+
relevance: 0
128+
}
129+
]),
130+
relevance: 0
131+
},
132+
{
133+
className: 'function',
134+
begin: '(' + hljs.IDENT_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
135+
returnBegin: true, end: /[{;=]/,
136+
excludeEnd: true,
137+
keywords: CPP_KEYWORDS,
138+
illegal: /[^\w\s\*&]/,
139+
contains: [
140+
{
141+
begin: FUNCTION_TITLE, returnBegin: true,
142+
contains: [hljs.TITLE_MODE],
143+
relevance: 0
144+
},
145+
{
146+
className: 'params',
147+
begin: /\(/, end: /\)/,
148+
keywords: CPP_KEYWORDS,
149+
relevance: 0,
150+
contains: [
151+
hljs.C_LINE_COMMENT_MODE,
152+
hljs.C_BLOCK_COMMENT_MODE,
153+
STRINGS,
154+
NUMBERS,
155+
CPP_PRIMITIVE_TYPES,
156+
// Count matching parentheses.
157+
{
158+
begin: /\(/, end: /\)/,
159+
keywords: CPP_KEYWORDS,
160+
relevance: 0,
161+
contains: [
162+
'self',
163+
hljs.C_LINE_COMMENT_MODE,
164+
hljs.C_BLOCK_COMMENT_MODE,
165+
STRINGS,
166+
NUMBERS,
167+
CPP_PRIMITIVE_TYPES
168+
]
169+
}
170+
]
171+
},
172+
hljs.C_LINE_COMMENT_MODE,
173+
hljs.C_BLOCK_COMMENT_MODE,
174+
PREPROCESSOR
175+
]
176+
},
177+
{
178+
className: 'class',
179+
beginKeywords: 'class struct', end: /[{;:]/,
180+
contains: [
181+
{begin: /</, end: />/, contains: ['self']}, // skip generic stuff
182+
hljs.TITLE_MODE
183+
]
184+
}
185+
]),
186+
exports: {
187+
preprocessor: PREPROCESSOR,
188+
strings: STRINGS,
189+
keywords: CPP_KEYWORDS
190+
}
191+
};
192+
}

0 commit comments

Comments
 (0)