git.iko.soy/typeable/pandoc
on master help sign in
Refactored LaTeX reader for clarity (added isArg function).
7384774fiddlosopher
src/Text/Pandoc/Readers/LaTeX.hs+5−1
@@ -51,6 +51,10 @@ bracketedText openB closeB = try (do
51-- | Returns an option or argument of a LaTeX command
51-- | Returns an option or argument of a LaTeX command
52optOrArg = choice [ (bracketedText '{' '}'), (bracketedText '[' ']') ]
52optOrArg = choice [ (bracketedText '{' '}'), (bracketedText '[' ']') ]
53
53
54+-- | True if the string begins with '{'
55+isArg ('{':rest) = True
56+isArg other = False
57+
54-- | Returns list of options and arguments of a LaTeX command
58-- | Returns list of options and arguments of a LaTeX command
55commandArgs = many optOrArg
59commandArgs = many optOrArg
56
60
@@ -549,7 +553,7 @@ link = try (do
549
553
550image = try (do
554image = try (do
551 ("includegraphics", _, args) <- command
555 ("includegraphics", _, args) <- command
552− let args' = filter (\arg -> (take 1 arg) /= "[") args
556+ let args' = filter isArg args -- filter out options
553 let src = if null args' then
557 let src = if null args' then
554 Src "" ""
558 Src "" ""
555 else
559 else