SIunitx.hs (pandoc-2.11.1.1) | : | SIunitx.hs (pandoc-2.11.2) | ||
---|---|---|---|---|
skipping to change at line 61 | skipping to change at line 61 | |||
skipopts | skipopts | |||
xs <- map tonum . T.splitOn ";" . untokenize <$> braced | xs <- map tonum . T.splitOn ";" . untokenize <$> braced | |||
case xs of | case xs of | |||
[] -> return mempty | [] -> return mempty | |||
[x] -> return x | [x] -> return x | |||
_ -> return $ | _ -> return $ | |||
mconcat (intersperse (str "," <> space) (init xs)) <> | mconcat (intersperse (str "," <> space) (init xs)) <> | |||
text ", & " <> last xs | text ", & " <> last xs | |||
parseNum :: Parser Text () Inlines | parseNum :: Parser Text () Inlines | |||
parseNum = mconcat <$> many parseNumPart | parseNum = (mconcat <$> many parseNumPart) <* eof | |||
parseNumPart :: Parser Text () Inlines | parseNumPart :: Parser Text () Inlines | |||
parseNumPart = | parseNumPart = | |||
parseDecimalNum <|> | parseDecimalNum <|> | |||
parseComma <|> | parseComma <|> | |||
parsePlusMinus <|> | parsePlusMinus <|> | |||
parseI <|> | parseI <|> | |||
parseExp <|> | parseExp <|> | |||
parseX <|> | parseX <|> | |||
parseSpace | parseSpace | |||
where | where | |||
parseDecimalNum = do | parseDecimalNum = do | |||
basenum <- T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.')) | pref <- option mempty $ (mempty <$ char '+') <|> ("\x2212" <$ char '-') | |||
basenum <- (pref <>) . T.pack | ||||
<$> many1 (satisfy (\c -> isDigit c || c == '.')) | ||||
uncertainty <- option mempty $ T.pack <$> parseParens | uncertainty <- option mempty $ T.pack <$> parseParens | |||
if T.null uncertainty | if T.null uncertainty | |||
then return $ str basenum | then return $ str basenum | |||
else return $ str $ basenum <> "\xa0\xb1\xa0" <> | else return $ str $ basenum <> "\xa0\xb1\xa0" <> | |||
let (_,ys) = T.break (=='.') basenum | let (_,ys) = T.break (=='.') basenum | |||
in case (T.length ys - 1, T.length uncertainty) of | in case (T.length ys - 1, T.length uncertainty) of | |||
(0,_) -> uncertainty | (0,_) -> uncertainty | |||
(x,y) | (x,y) | |||
| x > y -> "0." <> T.replicate (x - y) "0" <> | | x > y -> "0." <> T.replicate (x - y) "0" <> | |||
T.dropWhileEnd (=='0') uncertainty | T.dropWhileEnd (=='0') uncertainty | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added |