LaTeX reader: allow verbatim blocks ending with blank lines.
Closes #4624.
This commit is contained in:
parent
c6d56f026f
commit
190ee279c9
2 changed files with 44 additions and 1 deletions
|
@ -2145,7 +2145,20 @@ verbEnv name = withVerbatimMode $ do
|
|||
skipopts
|
||||
optional blankline
|
||||
res <- manyTill anyTok (end_ name)
|
||||
return $ stripTrailingNewlines $ toksToString res
|
||||
return $ T.unpack
|
||||
$ stripTrailingNewline
|
||||
$ untokenize
|
||||
$ res
|
||||
|
||||
-- Strip single final newline and any spaces following it.
|
||||
-- Input is unchanged if it doesn't end with newline +
|
||||
-- optional spaces.
|
||||
stripTrailingNewline :: Text -> Text
|
||||
stripTrailingNewline t =
|
||||
let (b, e) = T.breakOnEnd "\n" t
|
||||
in if T.all (== ' ') e
|
||||
then T.dropEnd 1 b
|
||||
else t
|
||||
|
||||
fancyverbEnv :: PandocMonad m => Text -> LP m Blocks
|
||||
fancyverbEnv name = do
|
||||
|
|
30
test/command/4624.md
Normal file
30
test/command/4624.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
```
|
||||
% pandoc -f latex -t native
|
||||
\begin{Verbatim}[key1=value1]
|
||||
code1
|
||||
|
||||
\end{Verbatim}
|
||||
|
||||
|
||||
\begin{lstlisting}[key2=value2]
|
||||
code2
|
||||
|
||||
\end{lstlisting}
|
||||
|
||||
\begin{verbatim}
|
||||
code3
|
||||
\end{verbatim}
|
||||
|
||||
\begin{verbatim}
|
||||
code4
|
||||
\end{verbatim}
|
||||
|
||||
\begin{verbatim}
|
||||
code5\end{verbatim}
|
||||
^D
|
||||
[CodeBlock ("",[],[("key1","value1")]) "code1\n"
|
||||
,CodeBlock ("",[],[("key2","value2")]) "code2\n "
|
||||
,CodeBlock ("",[],[]) "code3"
|
||||
,CodeBlock ("",[],[]) "code4"
|
||||
,CodeBlock ("",[],[]) "code5"]
|
||||
```
|
Loading…
Add table
Reference in a new issue