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.
This commit is contained in:
John MacFarlane
2020-11-16 14:08:29 -08:00
parent dcf99f29e0
commit 734b4c26a9
2 changed files with 19 additions and 2 deletions
+4 -2
View File
@@ -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
+15
View File
@@ -0,0 +1,15 @@
```
% pandoc -f latex
\SI{+33.3}{\m}
\num{+5}
\SI{-33.3}{\m}
\num{-33}
^D
<p>33.3 m</p>
<p>5</p>
<p>-33.3 m</p>
<p>-33</p>
```