mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-25 01:36:45 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
```
|
||||
Reference in New Issue
Block a user