diff --git a/autotests/folding/example.rmd.fold b/autotests/folding/example.rmd.fold
--- a/autotests/folding/example.rmd.fold
+++ b/autotests/folding/example.rmd.fold
@@ -1,7 +1,7 @@
---
-title: "test"
-author: "me"
-date: "07.10.2014"
+title: "test"
+author: "me"
+date: "07.10.2014"
output: html_document
---
diff --git a/autotests/folding/highlight.tex.fold b/autotests/folding/highlight.tex.fold
--- a/autotests/folding/highlight.tex.fold
+++ b/autotests/folding/highlight.tex.fold
@@ -1,11 +1,11 @@
% LaTeX test file for kate's syntax highlighting and code folding
\ordinaryLaTeXcommandwithoption[10pt,a4paper]{article}
-% BEGIN region
+% BEGIN region
%comment, this is all ok % $
\%no comments please
\\%comment
-% END of region
+% END of region
\newcommand{\nohighlighting}
@@ -17,16 +17,16 @@
\begin{environmentshavespecialcolors}
normal
-\end{environmentshavespecialcolors}
+\end{environmentshavespecialcolors}
$equations are green, \commands somewhat darker$
normal
$$equations are green, \commands somewhat darker$$
normal
\(
\frac{1}{2}
\begin{test}
-\end{test}
+\end{test}
\)
normal
\[
@@ -38,17 +38,17 @@
green\darkergreen
\begin{test}
\test
-\end{test}
-\end{equation}
+\end{test}
+\end{equation}
\begin{equation*}
green\darkergreen
%comment
\begin{test}
\test
-\end{test}
+\end{test}
\%no comment
-\end{equation*}
+\end{equation*}
\{ %this should be comment
@@ -86,7 +86,7 @@
\begin{alignat}{2}
A &= B &= C \\
A &= B &= C
-\end{alignat}
+\end{alignat}
normal text
\iffalse
@@ -108,7 +108,7 @@
\begin{array}[b]{r}
\left( x_1 x_2 \right)\\
\times \left( x'_1 x'_2 \right)
- \end{array}
+ \end{array}
}{
\left( y_1y_2y_3y_4 \right)
}
@@ -120,39 +120,39 @@
\textstyle f(x) = \textstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\scriptstyle f(x) = \scriptstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\scriptscriptstyle f(x) = \scriptscriptstyle \sum_{i=0}^{n} \frac{a_i}{1+x}
-\end{eqnarray*}
-\end{eqnarray*}
+\end{eqnarray*}
+\end{eqnarray*}
\begin{xalignat}{3}
i_{11} & =i_{23}\nonumber
-\end{xalignat}
+\end{xalignat}
c
\begin{equation}
c
\begin{aligned}
a & b\\
c & d
-\end{aligned}
+\end{aligned}
c
-\end{equation}
+\end{equation}
c
$$E=mc^2$$
\begin{equation}
E=m
-\end{equation}
+\end{equation}
\begin{equation
x=3\textrm{plop}
-\end{equation}
+\end{equation}
\[ \begin{array}{llll}
x^3 = (-x)^3 & \text{if $x > 0$}\\
x^3 = (-x)^3 & \text{if {$x > 0$}}\\
x^3 = (-x)^3 & \text{if {\color{green} $x > 0$}}\\
-\end{array} \]
+\end{array} \]
\section*{Notes for My Paper}
@@ -180,7 +180,7 @@
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular*}
-\end{center}
+\end{center}
\begin{tabularx}{1\textwidth}{ |>{\setlength\hsize{1\hsize}\centering}X|>{\setlength\hsize{1\hsize}\raggedleft}X@{} >{\setlength\hsize{1\hsize}\raggedright}X|>{\setlength\hsize{1\hsize}\centering}X| }
@@ -220,32 +220,32 @@
\end{lstlisting}
\begin{minted}{python}
-def foo(x):
+def foo(x):
return x
-\end{minted}
+\end{minted}
\begin{minted}
% blah blah
{python}
-def foo(x):
+def foo(x):
return x
-\end{minted}
+\end{minted}
\begin{minted}[frame=lines]{python}
-def foo(x):
+def foo(x):
return x
-\end{minted}
+\end{minted}
\begin{minted}
% plop
[frame=lines,
fontsize=\footnotesize
]
% ok
{python}
-def foo(x):
+def foo(x):
return x
-\end{minted}
+\end{minted}
\begin{comment}
This is a comment block.
@@ -259,21 +259,45 @@
Text that has a footnote\footnote{This $i_s$ the \[i_s\] $$x_i$$ \(x_i\)footnote}\addtocounter{footnote}{-1}\addtocounter{footnote}{-1} looks like this. Later text referring to same footnote\footnotemark uses the other command.
-\end{document}
+\end{document}
% A delimiter is not required before "\" in keywords of kind "\command" (see bug #413493)
-\begin{equation}123\end{equation}
+\begin{equation}123\end{equation}
\begin{comment}Comment\end{comment}
\iffalse text\fi normal text
text\begin{tabular}text\end{tabular}
-text\begin{a}text\end{a}
+text\begin{a}text\end{a}
% Close brackets correctly in some commands (see bug #415384)
\input{\a{}}
\cites{ text { text } text }
% Parentheses within [ ... ] (see bug #418979)
\cite[eq. (1.1)]{some_reference}
\cite[eq. \(x^n + y^n = z^n\)]{some reference}
+
+% Close folding correctly in "\end{...}" and in region markers (see bug #419125)
+\begin{document}
+ \begin{abstract}
+
+ \end{abstract}
+
+ \begin{itemize}
+ \item[\(\bullet\)]
+ %% BEGIN something
+ Here are some text describiing a new theorem. In the equation
+ \begin{equation}
+ E = mc^2
+ \end{equation}
+ we have a solution for energy-mass equivalence.
+ %% END
+
+ \item[\(\bullet\)]
+ \begin{align*}
+ B(z) &= p^r \sum_{k \geq 0} \binom{-r}{k} (-1)^k (1 - p)^k z^k \\
+ B(z) &= p^r \sum_{k \geq 0} \binom{-r}{k} (-(1-p) z)^k
+ \end{align*}
+ \end{itemize}
+\end{document}
diff --git a/autotests/html/highlight.tex.html b/autotests/html/highlight.tex.html
--- a/autotests/html/highlight.tex.html
+++ b/autotests/html/highlight.tex.html
@@ -283,4 +283,28 @@
% Parentheses within [ ... ] (see bug #418979)
\cite[eq. (1.1)]{some_reference}
\cite[eq. \(x^n + y^n = z^n\)]{some reference}
+
+% Close folding correctly in "\end{...}" and in region markers (see bug #419125)
+\begin{document}
+ \begin{abstract}
+
+ \end{abstract}
+
+ \begin{itemize}
+ \item[\(\bullet\)]
+ %% BEGIN something
+ Here are some text describiing a new theorem. In the equation
+ \begin{equation}
+ E = mc^2
+ \end{equation}
+ we have a solution for energy-mass equivalence.
+ %% END
+
+ \item[\(\bullet\)]
+ \begin{align*}
+ B(z) &= p^r \sum_{k \geq 0} \binom{-r}{k} (-1)^k (1 - p)^k z^k \\
+ B(z) &= p^r \sum_{k \geq 0} \binom{-r}{k} (-(1-p) z)^k
+ \end{align*}
+ \end{itemize}
+\end{document}