aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-07-16 13:42:34 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-07-16 13:42:34 -0700
commitc75faac1b517e8fb8ba5eea4c4bf7ea924f733b0 (patch)
tree44d9c7c04a293be71468fa233e19e930799e4484 /src/Text
parent0d72237e274fcb054459f547b6a9e3c206f92c39 (diff)
downloadpandoc-c75faac1b517e8fb8ba5eea4c4bf7ea924f733b0.tar.gz
LaTeX reader: handle \looseness command values better.
Closes #4439.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index 42e0c7360..a265d6ca2 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -646,18 +646,17 @@ dimenarg :: PandocMonad m => LP m Text
dimenarg = try $ do
optional sp
ch <- option False $ True <$ symbol '='
+ minus <- option "" $ "-" <$ symbol '-'
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.dropEnd 2 s
+ let (num, rest) = T.span (\c -> isDigit c || c == '.') s
guard $ T.length num > 0
- guard $ T.all (\c -> isDigit c || c == '.') num
- return $ T.pack ['=' | ch] <> s
+ guard $ rest `elem` ["", "pt","pc","in","bp","cm","mm","dd","cc","sp"]
+ return $ T.pack ['=' | ch] <> minus <> s
ignore :: (Monoid a, PandocMonad m) => String -> ParserT s u m a
ignore raw = do