% SYNTAX TEST "Packages/LaTeX/LaTeX.sublime-syntax"

% <- text.tex.latex

\documentclass[12pt]{article}
% ^ keyword.control.preamble.latex
%                    ^ support.class.latex

\usepackage[args]{mypackage, anotherpackage}
% ^ keyword.control.preamble.latex
%                 ^ support.class.latex
%                          ^ -support.class.latex
%                              ^ support.class.latex

\usepackage[pdftex,
            %plainpages={false},
%               ^ comment.line
            bookmarks=true,
%               ^ variable.parameter
            unicode=true,
            bookmarksnumbered={true},
            % pagebackref=true,
            breaklinks=true,
            pdfstartview={FitBH}]{hyperref}
%                                     ^ support.class.latex

% line comment
% <- comment.line.percentage.tex

\newcommand{\foo}{\bar}
%   ^ meta.function.newcommand.latex
%             ^support.function.latex entity.name.newcommand.latex
%                   ^ support.function.general.latex

\newcommand{\foo}[1]{\bar #1}
%   ^ meta.function.newcommand.latex
%             ^support.function.latex entity.name.newcommand.latex
%                      ^ support.function.general.latex

\newcommand{\foo}[2][default]{\bar #1 #2}
%   ^ meta.function.newcommand.latex
%             ^support.function.latex entity.name.newcommand.latex
%                               ^ support.function.general.latex

\newcolumntype{x}{>{$}c<{$}}
% ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.newcolumntype.latex
% ^ support.function.newcolumntype.latex
%                 ^ support.function.insert-before-column.latex
%                   ^ meta.function.before-column-decl.latex
%                     ^ meta.function.newcolumntype.latex keyword.other.column-type.latex
%                      ^ support.function.insert-after-column.latex
%                        ^ meta.function.after-column-decl.latex

\begin{document}
% ^ support.function.begin.latex keyword.control.flow.begin.latex
%        ^ variable.parameter.function.latex


% TEX INTERNAL COMMANDS
\\
% <- constant.character.newline.latex

\\[1.5ex]
% <- constant.character.newline.latex
% ^ punctuation.definition.group.bracket.begin.newline.latex
%  ^^^ constant.numeric.newline.latex
%     ^^ keyword.other.newline.latex
%       ^ punctuation.definition.group.bracket.begin.newline.latex


% SECTION COMMANDS

\part{name}
% <- meta.section.latex
% ^ support.function.section.latex
%     ^ entity.name.section.latex
\chapter{name}
% <- meta.section.latex
% ^ support.function.section.latex
%        ^ entity.name.section.latex
\section{name}
% <- meta.section.latex
% ^ support.function.section.latex
%        ^ entity.name.section.latex
\subsection{name}
% <- meta.section.latex
% ^ support.function.section.latex
%           ^ entity.name.section.latex
\subsubsection{name}
% <- meta.section.latex
% ^ support.function.section.latex
%              ^ entity.name.section.latex
\paragraph{name}
% <- meta.section.latex
% ^ support.function.section.latex
%          ^ entity.name.section.latex
\subparagraph{name}
% <- meta.section.latex
% ^ support.function.section.latex
%             ^ entity.name.section.latex


% REF/LABEL/CITE COMMANDS

\label{sec:name}
% ^ meta.function.label.latex
% ^ support.function.label.latex
%        ^ entity.name

\ref{sec:name}
% ^ meta.function.reference.latex
% ^ support.function.reference.latex keyword.other.reference.latex
%        ^ constant.other.reference

\cite{my:bib:key}
% ^ meta.function.citation.latex
% ^ support.function.cite.latex keyword.other.cite.latex
%        ^ constant.other.citation


\cite[\command]{my:bib:key}
% ^ meta.function.citation.latex
% ^ support.function.cite.latex
%           ^ support.function
%

\parencite[Propositon~1]{Ref}
% ^ meta.function.citation.latex
% ^ support.function.cite.latex
%          ^ meta.group.bracket.latex
%                         ^ constant.other.citation.latex

\parencites[Proposition~1]{Firstref}[p.~2]{SecondRef}
% ^ meta.function.citation.latex
% ^ support.function.cite.latex
%           ^ meta.group.bracket.latex
%                          ^ constant.other.citation.latex
%                                     ^ meta.group.bracket.latex
%                                          ^ constant.other.citation.latex

\Citeauthor*[]{ref}
% ^ meta.function.citation.latex
% ^ support.function.cite.latex
%          ^ support.function.cite.latex
%           ^ meta.group.bracket.latex
%              ^ constant.other.citation.latex


% URL COMMAND

\url{https://www.sublimetext.com/}
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.link.url.latex
% ^ support.function.url.latex
%    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.latex

\href{https://www.sublimetext.com/}
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.link.url.latex
% ^ support.function.url.latex
%     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.latex

\path{$HOME/path/to/file}
% ^^^^^^^^^^^^^^^^^^^^^^ meta.function.link.url.latex
% ^ support.function.url.latex
%     ^^^^^^^^^^^^^^^^^^ markup.underline.link.latex


% INCLUDE COMMANDS

\include{path/to/file}
% ^ meta.function.include.latex
% ^ keyword.control.include.latex

\includeonly{path/to/file.tex}
% ^ meta.function.include.latex
% ^ keyword.control.include.latex

\input{path/to/file.tex}
% ^ meta.function.input.tex
% ^ keyword.control.input.tex

\includecommand{...}
% ^^^^^^^^^^ support.function.general.latex

\inputminted{py}{path/to/file.py}
% ^^^^^^^^^^ support.function.general.latex


% MARKUP COMMANDS

\emph{text}
%     ^ markup.italic.emph.latex
\textbf{text}
%       ^ markup.bold.textbf.latex
\textit{text}
%       ^ markup.italic.textit.latex
\texttt{text}
%       ^ markup.raw.texttt.latex
\textsl{text}
%       ^ markup.italic.textsl.latex
\textbf{\textit{text}}
%               ^ markup.bold.textbf.latex markup.italic.textit.latex
\textit{\textbf{text}}
%               ^ markup.italic.textit.latex markup.bold.textbf.latex
\underline{text}
%          ^ markup.underline.underline.latex


% FOOTNOTE COMMANDS

\footnote{This is a basic footnote}
% ^^^^^^^ meta.function.footnote.latex support.function.footnote.latex
%        ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex
%         ^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex

\footnote [ 5 ] {This is a footnote with a specific reference mark}
% ^^^^^^^ meta.function.footnote.latex support.function.footnote.latex
%         ^ punctuation.definition.group.bracket.begin.latex
%         ^^^^^ meta.function.footnote.latex meta.group.bracket.latex
%             ^ punctuation.definition.group.bracket.end.latex
%               ^ punctuation.definition.group.brace.begin.latex
%               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex
%                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex
%                                                                 ^ punctuation.definition.group.brace.end.latex

\footnotetext{Footnote text without creating a mark}
% ^^^^^^^^^^^ meta.function.footnote.latex support.function.footnote.latex
%             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex
%                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex

\footnotemark
% ^^^^^^^^^^^ support.function.footnote.latex

\footnotemark  [ 1   ]
% ^^^^^^^^^^^ support.function.footnote.latex
%              ^ punctuation.definition.group.bracket.begin.latex
%              ^^^^^^^ meta.group.bracket.latex
%                    ^ punctuation.definition.group.bracket.end.latex

% LIST ENVIRONMENTS

\begin{itemize}
\item first item
% <- meta.environment.list.itemize.latex
\end{itemize}

\begin{enumerate}
\item first item
% <- meta.environment.list.enumerate.latex
\end{enumerate}

\begin{description}
\item[item] description of item
% <- meta.environment.list.description.latex
\end{description}

\begin{list}{(\arabic{listcounter})}{\usecounter{listcounter}}
\item first item
% <- meta.environment.list.list.latex
\end{list}

% VERBATIM

\command{}
% ^ support.function.general.latex
\verb|\command{}|
%      ^ markup.raw.verb.latex
%      ^ meta.environment.verbatim.verb.latex
%      ^ - support.function.general.latex
\verb+\command{}+
%      ^ markup.raw.verb.latex
%      ^ meta.environment.verbatim.verb.latex
%      ^ - support.function.general.latex
\verb|foo % bar|
% ^^^^^^^^^^^^^^ meta.environment.verbatim.verb.latex
%         ^^^^^ - comment

% <- - meta.environment.verbatim.verb.latex

\begin{verbatim}
% ^ support.function.begin.latex keyword.control.flow.begin.latex
%        ^ variable.parameter.function.latex
The \emph{verbatim} environment sets everything in verbatim.
% <- meta.environment.verbatim.verbatim.latex
% ^ markup.raw.verbatim.latex
%         ^ - markup.italic.emph.latex
\command{}
% ^ - support.function.general.latex
% This is not a comment
% <- - comment.line.percentage.tex
\end{verbatim}


% COMMANDS INSIDE ARGUMENTS

\makebox[\linewidth]{...}
% ^ support.function.box.latex
%         ^ support.function.general.latex

\includegraphics[width=0.33\textwidth, angle=30]{test.png}
% ^ support.function.includegraphics.latex
%                           ^ support.function.general.latex

% Neasted optional arguments
\includegraphics[width={\foo[argument]{bar}}]{test.png}
% ^ support.function.includegraphics.latex
%                        ^ meta.group.bracket.latex
%                          ^ support.function.general.latex
%                               ^ meta.group.bracket.latex
%                                     ^ punctuation.definition.group.brace.begin.latex
%                                        ^ meta.group.brace.latex
%                                         ^ punctuation.definition.group.brace.end.latex


% MATH

% Check we have always a shared environment

$f(x) = x^2$
% ^ meta.environment.math.inline
$$f(x) = x^2$$
% ^ meta.environment.math.block
\(f(x) = x^2\)
% ^ meta.environment.math.inline
\[
  f(x) = x^2 \text{ $f$ is a function}
% ^ meta.environment.math.block
\]
\ensuremath{f(x) = x^2}
%           ^ meta.environment.math.inline
\begin{equation}
f(x) = x^2
% ^ meta.environment.math.block
\end{equation}

$\iota$
% ^ keyword.other.greek.math.tex

$\Iota$
% ^ support.function.math.tex

$\alpha _$
% ^ keyword.other.greek.math.tex
%       ^ keyword.operator.math.tex

$\alpha_$
% ^ keyword.other.greek.math.tex
%      ^ keyword.operator.math.tex

% Boxes
\mbox{text}{text}
%       ^ meta.function.box.latex
%             ^ -meta.function.box.latex
\parbox{text}{text}{text}
%       ^ meta.function.box.latex
%             ^ meta.function.box.latex
%                    ^ -meta.function.box.latex

\makebox   \break
%        ^ meta.function.box.latex
%           ^ -meta.function.box.latex

% PACKAGE: comment
% The comment package can be used to write block comment
% using an environment.

\begin{comment}
% ^ support.function.begin.latex keyword.control.flow.begin.latex
%      ^ variable.parameter.function.latex
This environment can be used to write
% <- comment.block.environment.comment.latex
block comments.
% <- comment.block.environment.comment.latex
\end{comment}


\comment
% <- comment.block.command.comment.latex
% ^ punctuation.definition.comment.start.latex
This block comment can be done with
% <- comment.block.command.comment.latex
opening and closing commands.
% <- comment.block.command.comment.latex
\endcomment
% <- comment.block.command.comment.latex
% ^ punctuation.definition.comment.end.latex


% PACKAGE: listings
% The listings package is used to highlight source code.
% Supported languages:
% - python
% - java

\begin{lstlisting} % python
def my_function():
    pass
% <- meta.environment.verbatim.lstlisting.latex
% <- meta.environment.embedded.python.latex
% <- source.python.embedded
%   ^ keyword.control.flow.pass.python
\end{lstlisting}

\begin{lstlisting}[frame=single,
                   language=python] %python
def my_function():
    pass
% <- meta.environment.verbatim.lstlisting.latex
% <- meta.environment.embedded.python.latex
% <- source.python.embedded
%   ^ keyword.control.flow.pass.python
\end{lstlisting}

\begin{lstlisting} %java
class MyClass() {
% <- meta.environment.verbatim.lstlisting.latex
% <- meta.environment.embedded.java.latex
% <- source.java.embedded
% ^ storage.type.java
}
\end{lstlisting}

\lstinline{var x = 15;}
% ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex
%         ^^^^^^^^^^^^^ meta.group.brace.latex
%         ^ punctuation.definition.group.brace.begin.latex
%          ^^^^^^^^^^^ markup.raw.verb.latex
%                     ^ punctuation.definition.group.brace.end.latex
%                      ^ - meta.environment.verbatim.lstinline.latex

\lstinline|var x = 15;|
% ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex
%          ^^^^^^^^^^^ markup.raw.verb.latex
%                      ^ - meta.environment.verbatim.lstinline.latex


% PACKAGE: minted
% The minted package is used to highlight source code using
% the Pygments library.

\begin{minted}[linenos=true]{python}
def my_function():
    pass
% <- meta.environment.verbatim.minted.latex
% <- meta.environment.embedded.python.latex
% <- source.python.embedded
%   ^ keyword.control.flow.pass.python
\end{minted}


\mint{python}{import this}
%             ^ meta.environment.verbatim.minted.latex
%             ^ meta.environment.embedded.python.latex
%             ^ source.python.embedded
%             ^ keyword.control.import.python

% instead of embedding the code into { and } it is also possible
% to use an arbitrary character
\mint{python}|import this|
%             ^ meta.environment.verbatim.minted.latex
%             ^ source.python.embedded


\mintinline{python}{print(x ** 2)}
%                    ^ meta.environment.verbatim.minted.latex
%                    ^ meta.environment.embedded.python.latex
%                    ^ source.python.embedded
%                    ^ support.function.builtin.python

\mintinline{python}+print(x ** 2)+
%                    ^ source.python.embedded


% PACKAGE: array
% The array package extends array and tabular environments
% and allows for macros in format specifications

\begin{tabular}
% <- -meta.environment.tabular.latex
\end{tabular}

\begin{tabular}[t]{|x|@{See: }>{$}l<{$}|}
%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.tabular.latex - meta.environment.tabular.latex meta.environment.tabular.latex
%                 ^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.tabular.latex meta.function.column-spec.latex
%                  ^ keyword.operator.inter-column-line.latex
%                     ^ support.function.inter-column-nospace.latex

\hline

a & b
% <- meta.environment.tabular.latex

\hline

\end{tabular}
% ^^^^^^^^^^^ meta.environment.tabular.latex - meta.environment.tabular.latex meta.environment.tabular.latex
%     ^ variable.parameter.function.latex


\begin{tabular}{*{3}{>{$}c<{$}}}
%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.tabular.latex - meta.environment.tabular.latex meta.environment.tabular.latex
%               ^ support.function.insert-repeated.latex
%                ^^^ meta.function.insert-repeated-count.latex
%                 ^ constant.numeric.array-count.latex
%                    ^ support.function.insert-before-column.latex
%                   ^^^^^^^^^^^ meta.function.insert-repeated-content.latex
%                         ^ support.function.insert-after-column.latex
    a & b & c \\\hline
    1 & 2 & 3
\end{tabular}


% issue 1280

\begin{tabular}{p{2.6cm} | p{6.0cm} }
%               ^^^^^^^^^^^^^^^^^^^ meta.environment.tabular meta.function.column-spec
%               ^ support.function.parbox-column
%                        ^ keyword.operator.inter-column-line
%                          ^ support.function.parbox-column
%                                  ^ meta.environment.tabular meta.function.column-spec
\end{tabular}



\AnyDeclarationCommand{\eq}{\begin{equation}}

% <- - meta.environment.math

\wrapcommand{$}

% <- - meta.environment.math

\wrapcommand{\[}

% <- - meta.environment.math

$f(x) = \} {} y$
% ^^^^^^^^^^^^^ meta.environment.math.inline.dollar.latex


\end{document}
% ^ support.function.end.latex keyword.control.flow.end.latex
%        ^ variable.parameter.function.latex
