git.iko.soy/typeable/pandoc
on master help sign in
Improved uncertainty handling in slunitx.
commit623ce89e0eb08d1878b4a006d32a7c2986b3494a authorJohn MacFarlane <jgm@berkeley.edu> dateThu 10 Sep 2020, 14:48 (6 years ago) parenta03160f
2 files changed+14−6
src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+11−6 test/command/6620.md+3
src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+11−6
@@ -76,12 +76,17 @@ parseNumPart =
7676 if T.null uncertainty
7777 then return $ str basenum
7878 else return $ str $ basenum <> "\xa0\xb1\xa0" <>
79− case T.break (=='.') basenum of
80− (_,ys)
81− | T.length ys <= 1 -> uncertainty
82− | otherwise -> "0." <>
83− T.replicate (T.length ys - 1 - T.length uncertainty) "0"
84− <> uncertainty
79+ let (_,ys) = T.break (=='.') basenum
80+ in case (T.length ys - 1, T.length uncertainty) of
81+ (0,_) -> uncertainty
82+ (x,y)
83+ | x > y -> "0." <> T.replicate (x - y) "0" <>
84+ T.dropWhileEnd (=='0') uncertainty
85+ | otherwise -> T.take (y - x) uncertainty <>
86+ case T.dropWhileEnd (=='0')
87+ (T.drop (y - x) uncertainty) of
88+ t | T.null t -> mempty
89+ | otherwise -> "." <> t
8590 parseComma = str "." <$ char ','
8691 parsePlusMinus = str "\xa0\xb1\xa0" <$ try (string "+-")
8792 parseParens =
test/command/6620.md+3
@@ -5,8 +5,11 @@
55\SI{125(12)}{\m}
66
77\SI{0.135(21)}{\m}
8+
9+\SI{12.3(60)}{\m}
810^D
911<p>23 ± 2 m</p>
1012<p>125 ± 12 m</p>
1113<p>0.135 ± 0.021 m</p>
14+<p>12.3 ± 6 m</p>
1215```