aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-11-19 00:17:22 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2018-11-19 00:17:22 -0800
commit1a679a4d6e99f4bdb19f1f546a0ccf856ba00cf4 (patch)
tree06dc3d1cfb149555d7e5dd22d689721c0af8ee8f /src/Text/Pandoc/Readers/LaTeX
parentfda3e401633c2d9441539670c8248a2b5d09b831 (diff)
downloadpandoc-1a679a4d6e99f4bdb19f1f546a0ccf856ba00cf4.tar.gz
LaTeX reader: cleaned up handling of dimension arguments.
Allow decimal points, preceding space. Also require text 1.1+.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index 69bbf28d4..c5385bedc 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -105,7 +105,7 @@ import Text.Pandoc.Error (PandocError (PandocMacroLoop))
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (blankline, many, mathDisplay, mathInline,
- optional, space, spaces, withRaw, (<|>))
+ space, spaces, withRaw, (<|>))
import Text.Pandoc.Readers.LaTeX.Types (ExpansionPoint (..), Macro (..),
ArgSpec (..), Tok (..), TokType (..))
import Text.Pandoc.Shared
@@ -668,13 +668,19 @@ parenWrapped parser = try $ do
dimenarg :: PandocMonad m => LP m Text
dimenarg = try $ do
+ optional sp
ch <- option False $ True <$ symbol '='
- Tok _ _ s <- satisfyTok isWordTok
- guard $ T.take 2 (T.reverse s) `elem`
+ Tok _ _ s1 <- satisfyTok isWordTok
+ s2 <- option "" $ try $ do
+ symbol '.'
+ Tok _ _ t <- satisfyTok isWordTok
+ return ("." <> t)
+ let s = s1 <> s2
+ guard $ T.takeEnd 2 s `elem`
["pt","pc","in","bp","cm","mm","dd","cc","sp"]
- let num = T.take (T.length s - 2) s
+ let num = T.dropEnd 2 s
guard $ T.length num > 0
- guard $ T.all isDigit num
+ guard $ T.all (\c -> isDigit c || c == '.') num
return $ T.pack ['=' | ch] <> s
ignore :: (Monoid a, PandocMonad m) => String -> ParserT s u m a