forked from ccampbell/rainbow
/
latex.js
49 lines (49 loc) · 1.06 KB
/
latex.js
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
/**
* LaTeX patterns
*
* @author Sean Allred <code@seanallred.com>
* @version 1.0
*/
Rainbow.extend('latex', [
{
'name': 'tex.comment',
'pattern': /%.*$/gm
},
{
'name': 'tex.macro',
'pattern': /\\([A-Za-z@]+\*?|.)/g
},
{
'matches':
{
1: 'tex.macro',
2: 'tex.environment'
},
'pattern': /(\\(?:begin|end|documentclass))\s*\{(.*?)\}/g
},
{
'name': 'tex.math',
'pattern': /\$.*?\$/g
},
{
'matches':
{
1: 'tex.doc.section.tag',
2: 'tex.doc.section'
},
'pattern': /(\\(?:(?:sub)?paragraph|(?:sub){0,3}section|chapter|part)\*?)\{(.*?)\}/g
},
{
'name': 'tex.macro.parameter',
'pattern': /#\d/g
},
{
'matches':
{
1: 'tex.special.newcommand',
2: 'tex.special.newcommand.command',
3: 'tex.special.newcommand.parameter'
},
'pattern': /(\\newcommand\*?)\s*\{?(\\[A-Za-z])\}?(\[\d\])?/g
}
], true)