Skip to content

Commit

Permalink
LaTeX: Regexp optimisation and simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent 12ff8dc commit aa426b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions components/prism-latex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(Prism) {
var funcPattern = /\\([^a-z()[\]]|[a-z\*]+)/i,
var funcPattern = /\\(?:[^a-z()[\]]|[a-z*]+)/i,
insideEqu = {
'equation-command': {
pattern: funcPattern,
Expand All @@ -11,7 +11,7 @@
'comment': /%.*/m,
// the verbatim environment prints whitespace to the document
'cdata': {
pattern: /(\\begin\{((?:verbatim|lstlisting)\*?)\})([\s\S]*?)(?=\\end\{\2\})/,
pattern: /(\\begin\{((?:verbatim|lstlisting)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
lookbehind: true
},
/*
Expand All @@ -20,12 +20,12 @@
*/
'equation': [
{
pattern: /\$(?:\\?[\s\S])*?\$|\\\((?:\\?[\s\S])*?\\\)|\\\[(?:\\?[\s\S])*?\\\]/,
pattern: /\$(?:\\[\s\S]|[^\\$])*\$|\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]/,
inside: insideEqu,
alias: 'string'
},
{
pattern: /(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})([\s\S]*?)(?=\\end\{\2\})/,
pattern: /(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
lookbehind: true,
inside: insideEqu,
alias: 'string'
Expand Down
2 changes: 1 addition & 1 deletion components/prism-latex.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aa426b0

Please sign in to comment.