diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-09-10 13:07:31 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-09-10 13:07:31 -0700 |
commit | a03160fb0d9c9790e23f6c75368bfa39281b76a8 (patch) | |
tree | 1287282b95137e6e3539e5aabccaa5d2b4033e3d /src/Text/Pandoc | |
parent | 9423b4b7d91b38540388d0183d49cc413538edb9 (diff) | |
download | pandoc-a03160fb0d9c9790e23f6c75368bfa39281b76a8.tar.gz |
LaTeX reader: support parenthesized uncertainties in siunitx.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/SIunitx.hs | 16 |
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) |