Skip to content

Commit

Permalink
Fix keyval funtion: pandoc did not parse options in braces correctly.… (
Browse files Browse the repository at this point in the history
#3642)

* Fix keyval funtion: pandoc did not parse options in braces correctly. Additionally, dot, dash, and colon were no valid characters

* Add | as possible option value

* Improved code
  • Loading branch information
schrieveslaach authored and jgm committed May 6, 2017
1 parent f422000 commit ddf2524
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Readers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ parseListingsOptions options =
keyval :: PandocMonad m => LP m (String, String)
keyval = try $ do
key <- many1 alphaNum
val <- option "" $ char '=' >> many1 (alphaNum <|> char '.' <|> char '\\')
val <- option "" $ char '=' >> braced <|> (many1 (alphaNum <|> oneOf ".:-|\\"))
skipMany spaceChar
optional (char ',')
skipMany spaceChar
Expand Down
25 changes: 25 additions & 0 deletions test/command/lstlisting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```
% pandoc -f latex -t native
\begin{lstlisting}[language=Java, caption={Java Example}, label=lst:Hello-World]
public class World {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
\end{lstlisting}
^D
[CodeBlock ("lst:Hello-World",["java"],[("language","Java"),("caption","Java Example"),("label","lst:Hello-World")]) "public class World {\n public static void main(String[] args) {\n System.out.println(\"Hello World\");\n }\n}"]
```

```
% pandoc -f latex -t native
\begin{lstlisting}[language=Java, escapechar=|, caption={Java Example}, label=lst:Hello-World]
public class World {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
\end{lstlisting}
^D
[CodeBlock ("lst:Hello-World",["java"],[("language","Java"),("escapechar","|"),("caption","Java Example"),("label","lst:Hello-World")]) "public class World {\n public static void main(String[] args) {\n System.out.println(\"Hello World\");\n }\n}"]
```

0 comments on commit ddf2524

Please sign in to comment.