diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-05-20 09:03:29 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-05-20 09:03:29 -0700 |
commit | a366bd6abccd18a49f0033de850ddd53830cc5ed (patch) | |
tree | 45258c1b7005e6ad30dd963e2e5b10c7550a15fe /src/Text/Pandoc/Readers/LaTeX | |
parent | 8437a4a002210a33ee721c58f5f95605898a8e1b (diff) | |
download | pandoc-a366bd6abccd18a49f0033de850ddd53830cc5ed.tar.gz |
LaTeX reader: Fix parsing of `+-` in siunitx numbers.
See #6658.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/SIunitx.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs index c4fb06700..5e140ef7a 100644 --- a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs +++ b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs @@ -45,9 +45,7 @@ doSI tok = do unit] doSInum :: PandocMonad m => LP m Inlines -doSInum = skipopts *> (tonum . untokenize . map convertPM <$> braced) - where convertPM (Tok pos (CtrlSeq "pm") _) = Tok pos Word "\xb1\xa0" - convertPM t = t +doSInum = skipopts *> (tonum . untokenize <$> braced) tonum :: Text -> Inlines tonum value = @@ -74,12 +72,16 @@ parseNumPart = parseDecimalNum <|> parseComma <|> parsePlusMinus <|> + parsePM <|> parseI <|> parseExp <|> parseX <|> parseSpace where - parseDecimalNum = do + parseDecimalNum, parsePlusMinus, parsePM, + parseComma, parseI, parseX, + parseExp, parseSpace :: Parser Text () Inlines + parseDecimalNum = try $ do pref <- option mempty $ (mempty <$ char '+') <|> ("\x2212" <$ char '-') basenum <- (pref <>) . T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.')) @@ -100,6 +102,7 @@ parseNumPart = | otherwise -> "." <> t parseComma = str "." <$ char ',' parsePlusMinus = str "\xa0\xb1\xa0" <$ try (string "+-") + parsePM = str "\xa0\xb1\xa0" <$ try (string "\\pm") parseParens = char '(' *> many1 (satisfy (\c -> isDigit c || c == '.')) <* char ')' parseI = str "i" <$ char 'i' |