aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 91462caca..fe46d2e4f 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -185,7 +185,9 @@ hrule = try (do
-- code blocks
--
-codeBlock = try (do
+codeBlock = codeBlock1 <|> codeBlock2
+
+codeBlock1 = try (do
string "\\begin{verbatim}" -- don't use begin function because it
-- gobbles whitespace
option "" blanklines -- we want to gobble blank lines, but not
@@ -194,6 +196,13 @@ codeBlock = try (do
spaces
return (CodeBlock (stripTrailingNewlines contents)))
+codeBlock2 = try (do
+ string "\\begin{Verbatim}" -- used by fancyverb package
+ option "" blanklines
+ contents <- manyTill anyChar (try (string "\\end{Verbatim}"))
+ spaces
+ return (CodeBlock (stripTrailingNewlines contents)))
+
--
-- block quotes
--
@@ -518,13 +527,25 @@ gt = try (do
string "\\textgreater"
return (Str ">"))
-code = try (do
+code = code1 <|> code2
+
+code1 = try (do
string "\\verb"
marker <- anyChar
result <- manyTill anyChar (char marker)
let result' = removeLeadingTrailingSpace result
return (Code result'))
+-- examplep package uses \Q{} with backslash-escaped symbols
+code2 = try (do
+ string "\\Q{"
+ result <- manyTill (alphaNum <|>
+ try (do{char '\\'; oneOf "XSVB"; return ' '}) <|>
+ try (do{string "\\n"; return '\n'}) <|>
+ try (do{char '\\'; anyChar})) (char '}')
+ let result' = removeLeadingTrailingSpace result
+ return (Code result'))
+
emph = try (do
oneOfStrings [ "\\emph{", "\\textit{" ]
result <- manyTill inline (char '}')