diff options
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 8 | ||||
| -rw-r--r-- | test/command/11266.md | 19 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index e10556cee..a0ecf687d 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -1375,7 +1375,7 @@ ldfLanguages = isMathEnv :: Text -> Bool isMathEnv t = - case T.stripPrefix "\\begin{" t of + case T.stripPrefix "\\begin{" (T.dropWhile isSpaceChar t) of Nothing -> False Just t' -> T.takeWhile (/= '}') t' `elem` [ "align", "align*" @@ -1392,6 +1392,12 @@ isMathEnv t = , "eqnarray" , "displaymath" ] + where + isSpaceChar '\n' = True + isSpaceChar '\r' = True + isSpaceChar '\t' = True + isSpaceChar ' ' = True + isSpaceChar _ = False -- True if the math needs the cancel package needsCancel :: Text -> Bool diff --git a/test/command/11266.md b/test/command/11266.md new file mode 100644 index 000000000..e7c5ae73e --- /dev/null +++ b/test/command/11266.md @@ -0,0 +1,19 @@ +``` +% pandoc -t latex +$$ +\begin{eqnarray} +S &\rightarrow& a A \nonumber \\ +A &\rightarrow& d B \ | \ b A \ | \ c A \nonumber \\ +B &\rightarrow& a c \ | \ b C \ | \ c A \nonumber \\ +C &\rightarrow& \epsilon \nonumber +\end{eqnarray} +$$ +^D + +\begin{eqnarray} +S &\rightarrow& a A \nonumber \\ +A &\rightarrow& d B \ | \ b A \ | \ c A \nonumber \\ +B &\rightarrow& a c \ | \ b C \ | \ c A \nonumber \\ +C &\rightarrow& \epsilon \nonumber +\end{eqnarray} +``` |
