main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
2.1 KB
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | module.exports = latex
|
---|
4 | latex.displayName = 'latex'
|
---|
5 | latex.aliases = ['tex', 'context']
|
---|
6 | function latex(Prism) {
|
---|
7 | ;(function (Prism) {
|
---|
8 | var funcPattern = /\\(?:[^a-z()[\]]|[a-z*]+)/i
|
---|
9 | var insideEqu = {
|
---|
10 | 'equation-command': {
|
---|
11 | pattern: funcPattern,
|
---|
12 | alias: 'regex'
|
---|
13 | }
|
---|
14 | }
|
---|
15 | Prism.languages.latex = {
|
---|
16 | comment: /%.*/,
|
---|
17 | // the verbatim environment prints whitespace to the document
|
---|
18 | cdata: {
|
---|
19 | pattern:
|
---|
20 | /(\\begin\{((?:lstlisting|verbatim)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
|
---|
21 | lookbehind: true
|
---|
22 | },
|
---|
23 | /*
|
---|
24 | * equations can be between $$ $$ or $ $ or \( \) or \[ \]
|
---|
25 | * (all are multiline)
|
---|
26 | */
|
---|
27 | equation: [
|
---|
28 | {
|
---|
29 | pattern:
|
---|
30 | /\$\$(?:\\[\s\S]|[^\\$])+\$\$|\$(?:\\[\s\S]|[^\\$])+\$|\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]/,
|
---|
31 | inside: insideEqu,
|
---|
32 | alias: 'string'
|
---|
33 | },
|
---|
34 | {
|
---|
35 | pattern:
|
---|
36 | /(\\begin\{((?:align|eqnarray|equation|gather|math|multline)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
|
---|
37 | lookbehind: true,
|
---|
38 | inside: insideEqu,
|
---|
39 | alias: 'string'
|
---|
40 | }
|
---|
41 | ],
|
---|
42 | /*
|
---|
43 | * arguments which are keywords or references are highlighted
|
---|
44 | * as keywords
|
---|
45 | */
|
---|
46 | keyword: {
|
---|
47 | pattern:
|
---|
48 | /(\\(?:begin|cite|documentclass|end|label|ref|usepackage)(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
|
---|
49 | lookbehind: true
|
---|
50 | },
|
---|
51 | url: {
|
---|
52 | pattern: /(\\url\{)[^}]+(?=\})/,
|
---|
53 | lookbehind: true
|
---|
54 | },
|
---|
55 | /*
|
---|
56 | * section or chapter headlines are highlighted as bold so that
|
---|
57 | * they stand out more
|
---|
58 | */
|
---|
59 | headline: {
|
---|
60 | pattern:
|
---|
61 | /(\\(?:chapter|frametitle|paragraph|part|section|subparagraph|subsection|subsubparagraph|subsubsection|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
|
---|
62 | lookbehind: true,
|
---|
63 | alias: 'class-name'
|
---|
64 | },
|
---|
65 | function: {
|
---|
66 | pattern: funcPattern,
|
---|
67 | alias: 'selector'
|
---|
68 | },
|
---|
69 | punctuation: /[[\]{}&]/
|
---|
70 | }
|
---|
71 | Prism.languages.tex = Prism.languages.latex
|
---|
72 | Prism.languages.context = Prism.languages.latex
|
---|
73 | })(Prism)
|
---|
74 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.