-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'LatexBranch' of https://github.com/zeitgeist87/prism in…
…to gh-pages + update tests Conflicts: components/prism-latex.js components/prism-latex.min.js
- Loading branch information
Showing
9 changed files
with
294 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,61 @@ | ||
Prism.languages.latex = { | ||
'comment': /%.*/m, | ||
'string': /(\$)(\\?.)*?\1/, | ||
'punctuation': /[{}]/, | ||
'selector': /\\[a-z;,:\.]*/i | ||
}; | ||
(function(Prism) { | ||
var funcPattern = /\\([^a-z()[\]]|[a-z\*]+)/i, | ||
insideEqu = { | ||
'equation-command': { | ||
pattern: funcPattern, | ||
alias: 'regex' | ||
} | ||
}; | ||
|
||
Prism.languages.latex = { | ||
'comment': /%.*/m, | ||
// the verbatim environment prints whitespace to the document | ||
'cdata': { | ||
pattern: /(\\begin\{((?:verbatim|lstlisting)\*?)\})([\w\W]*?)(?=\\end\{\2\})/, | ||
lookbehind: true | ||
}, | ||
/* | ||
* equations can be between $ $ or \( \) or \[ \] | ||
* (all are multiline) | ||
*/ | ||
'equation': [ | ||
{ | ||
pattern: /\$(?:\\?[\w\W])*?\$|\\\((?:\\?[\w\W])*?\\\)|\\\[(?:\\?[\w\W])*?\\\]/, | ||
inside: insideEqu, | ||
alias: 'string' | ||
}, | ||
{ | ||
pattern: /(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})([\w\W]*?)(?=\\end\{\2\})/, | ||
lookbehind: true, | ||
inside: insideEqu, | ||
alias: 'string' | ||
} | ||
], | ||
/* | ||
* arguments which are keywords or references are highlighted | ||
* as keywords | ||
*/ | ||
'keyword': { | ||
pattern: /(\\(?:begin|end|ref|cite|label|usepackage|documentclass)(?:\[[^\]]+\])?\{)[^}]+(?=\})/, | ||
lookbehind: true | ||
}, | ||
'url': { | ||
pattern: /(\\url\{)[^}]+(?=\})/, | ||
lookbehind: true | ||
}, | ||
/* | ||
* section or chapter headlines are highlighted as bold so that | ||
* they stand out more | ||
*/ | ||
'headline': { | ||
pattern: /(\\(?:part|chapter|section|subsection|frametitle|subsubsection|paragraph|subparagraph|subsubparagraph|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\}(?:\[[^\]]+\])?)/, | ||
lookbehind: true, | ||
alias: 'class-name' | ||
}, | ||
'function': { | ||
pattern: funcPattern, | ||
alias: 'selector' | ||
}, | ||
'punctuation': /[[\]{}&]/ | ||
}; | ||
})(Prism); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
\begin{verbatim*} | ||
Foo bar | ||
\end{verbatim*} | ||
|
||
\begin{lstlisting} | ||
Foo bar | ||
baz | ||
\end{lstlisting} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "verbatim*"], ["punctuation", "}"], | ||
["cdata", "\r\nFoo bar\r\n"], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "verbatim*"], ["punctuation", "}"], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "lstlisting"], ["punctuation", "}"], | ||
["cdata", "\r\nFoo bar\r\nbaz\r\n"], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "lstlisting"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for verbatim environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
$foo$ | ||
$a \dots | ||
b$ | ||
\(foo\) | ||
\(a \dots | ||
b\) | ||
\[foo\] | ||
\[a \dots | ||
b\] | ||
|
||
\begin{equation}foo\end{equation} | ||
\begin{equation}a \dots | ||
b\end{equation} | ||
\begin{math}foo\end{math} | ||
\begin{math}a \dots | ||
b\end{math} | ||
\begin{eqnarray}foo\end{eqnarray} | ||
\begin{eqnarray}a \dots | ||
b\end{eqnarray} | ||
\begin{align}foo\end{align} | ||
\begin{align*}a \dots | ||
b\end{align*} | ||
\begin{multline}foo\end{multline} | ||
\begin{multline}a \dots | ||
b\end{multline} | ||
\begin{gather}foo\end{gather} | ||
\begin{gather}a \dots | ||
b\end{gather} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["equation", ["$foo$"]], | ||
["equation", [ | ||
"$a ", | ||
["equation-command", "\\dots"], | ||
"\r\nb$" | ||
]], | ||
["equation", ["\\(foo\\)"]], | ||
["equation", [ | ||
"\\(a ", | ||
["equation-command", "\\dots"], | ||
"\r\nb\\)" | ||
]], | ||
["equation", ["\\[foo\\]"]], | ||
["equation", [ | ||
"\\[a ", | ||
["equation-command", "\\dots"], | ||
"\r\nb\\]" | ||
]], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "equation"], ["punctuation", "}"], | ||
["equation", ["foo"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "equation"], ["punctuation", "}"], | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "equation"], ["punctuation", "}"], | ||
["equation", ["a ", ["equation-command", "\\dots"], "\r\nb"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "equation"], ["punctuation", "}"], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "math"], ["punctuation", "}"], | ||
["equation", ["foo"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "math"], ["punctuation", "}"], | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "math"], ["punctuation", "}"], | ||
["equation", ["a ", ["equation-command", "\\dots"], "\r\nb"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "math"], ["punctuation", "}"], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "eqnarray"], ["punctuation", "}"], | ||
["equation", ["foo"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "eqnarray"], ["punctuation", "}"], | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "eqnarray"], ["punctuation", "}"], | ||
["equation", ["a ", ["equation-command", "\\dots"], "\r\nb"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "eqnarray"], ["punctuation", "}"], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "align"], ["punctuation", "}"], | ||
["equation", ["foo"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "align"], ["punctuation", "}"], | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "align*"], ["punctuation", "}"], | ||
["equation", ["a ", ["equation-command", "\\dots"], "\r\nb"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "align*"], ["punctuation", "}"], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "multline"], ["punctuation", "}"], | ||
["equation", ["foo"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "multline"], ["punctuation", "}"], | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "multline"], ["punctuation", "}"], | ||
["equation", ["a ", ["equation-command", "\\dots"], "\r\nb"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "multline"], ["punctuation", "}"], | ||
|
||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "gather"], ["punctuation", "}"], | ||
["equation", ["foo"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "gather"], ["punctuation", "}"], | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "gather"], ["punctuation", "}"], | ||
["equation", ["a ", ["equation-command", "\\dots"], "\r\nb"]], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "gather"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for equations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
\part{Foobar} | ||
\chapter{Foobar} | ||
\section{Foobar} | ||
\subsection{Foobar} | ||
\frametitle{Foobar} | ||
\subsubsection{Foobar} | ||
\paragraph{Foobar} | ||
\subparagraph{Foobar} | ||
\subsubparagraph{Foobar} | ||
\subsubsubparagraph{Foobar} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "\\part"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\chapter"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\section"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\subsection"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\frametitle"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\subsubsection"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\paragraph"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\subparagraph"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\subsubparagraph"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"], | ||
["function", "\\subsubsubparagraph"], ["punctuation", "{"], | ||
["headline", "Foobar"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for headlines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
\begin{foobar} | ||
\end{foobar} | ||
\ref{foobar} | ||
\cite{foobar} | ||
\label{foobar} | ||
\usepackage{foobar} | ||
\documentclass[11px,twoside,a4paper]{foobar} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "\\begin"], ["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"], | ||
["function", "\\end"], ["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"], | ||
["function", "\\ref"], ["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"], | ||
["function", "\\cite"], ["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"], | ||
["function", "\\label"], ["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"], | ||
["function", "\\usepackage"], ["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"], | ||
["function", "\\documentclass"], | ||
["punctuation", "["], "11px,twoside,a4paper", ["punctuation", "]"], | ||
["punctuation", "{"], | ||
["keyword", "foobar"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for keywords. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
\url{http://prismjs.com} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "\\url"], ["punctuation", "{"], | ||
["url", "http://prismjs.com"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for URLs. |