aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/SIunitx.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
index 052a9d82e..9a14c9a3e 100644
--- a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
@@ -70,10 +70,22 @@ parseNumPart =
parseX <|>
parseSpace
where
- parseDecimalNum =
- str . T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.'))
+ parseDecimalNum = do
+ basenum <- T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.'))
+ uncertainty <- option mempty $ T.pack <$> parseParens
+ if T.null uncertainty
+ then return $ str basenum
+ else return $ str $ basenum <> "\xa0\xb1\xa0" <>
+ case T.break (=='.') basenum of
+ (_,ys)
+ | T.length ys <= 1 -> uncertainty
+ | otherwise -> "0." <>
+ T.replicate (T.length ys - 1 - T.length uncertainty) "0"
+ <> uncertainty
parseComma = str "." <$ char ','
parsePlusMinus = str "\xa0\xb1\xa0" <$ try (string "+-")
+ parseParens =
+ char '(' *> many1 (satisfy (\c -> isDigit c || c == '.')) <* char ')'
parseI = str "i" <$ char 'i'
parseX = str "\xa0\xd7\xa0" <$ char 'x'
parseExp = (\n -> str ("\xa0\xd7\xa0" <> "10") <> superscript n)