From 734b4c26a990a334b2bbe352ba34257ebb2a6fcd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 16 Nov 2020 14:07:31 -0800 Subject: LaTeX reader: Fix negative numbers in siunitx commands. The commit a157e1a broke negative numbers, e.g. `\SI{-33}{\celcius}` or `\num{-3}`. This fixes the regression. --- src/Text/Pandoc/Readers/LaTeX/SIunitx.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs index 436330d85..d16dec580 100644 --- a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs +++ b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs @@ -58,7 +58,7 @@ doSInumlist = do text ", & " <> last xs parseNum :: Parser Text () Inlines -parseNum = mconcat <$> many parseNumPart +parseNum = (mconcat <$> many parseNumPart) <* eof parseNumPart :: Parser Text () Inlines parseNumPart = @@ -71,7 +71,9 @@ parseNumPart = parseSpace where parseDecimalNum = do - basenum <- T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.')) + pref <- option mempty $ (mempty <$ char '+') <|> ("-" <$ char '-') + basenum <- (pref <>) . T.pack + <$> many1 (satisfy (\c -> isDigit c || c == '.')) uncertainty <- option mempty $ T.pack <$> parseParens if T.null uncertainty then return $ str basenum -- cgit v1.2.3