From 5271c6b3fbdc72d6a3e0405718f7c98cdf47eda0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 16 Nov 2020 16:36:16 -0800 Subject: Improve fix to siunitx numbers with minus. - use real minus sign - use tests contributed by Igor Pashev. --- src/Text/Pandoc/Readers/LaTeX/SIunitx.hs | 2 +- test/command/6844.md | 27 +++++++++++++++++++++++++++ test/command/siunitx-negative-numbers.md | 15 --------------- 3 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 test/command/6844.md delete mode 100644 test/command/siunitx-negative-numbers.md diff --git a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs index d16dec580..db9c276e7 100644 --- a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs +++ b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs @@ -71,7 +71,7 @@ parseNumPart = parseSpace where parseDecimalNum = do - pref <- option mempty $ (mempty <$ char '+') <|> ("-" <$ char '-') + pref <- option mempty $ (mempty <$ char '+') <|> ("\x2212" <$ char '-') basenum <- (pref <>) . T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.')) uncertainty <- option mempty $ T.pack <$> parseParens diff --git a/test/command/6844.md b/test/command/6844.md new file mode 100644 index 000000000..0431cfed8 --- /dev/null +++ b/test/command/6844.md @@ -0,0 +1,27 @@ +Negative numbers with siunitx + +``` +% pandoc -f latex -t native +\SI{123}{\celsius} + +^D +[Para [Str "123\160\176C"]] +``` + +``` +% pandoc -f latex -t native +\SI{-123}{\celsius} + +^D +[Para [Str "\8722\&123\160\176C"]] +``` + +``` +% pandoc -f latex -t native +\SI{+123}{\celsius} + +^D +[Para [Str "123\160\176C"]] +``` + + diff --git a/test/command/siunitx-negative-numbers.md b/test/command/siunitx-negative-numbers.md deleted file mode 100644 index 56cdbe31d..000000000 --- a/test/command/siunitx-negative-numbers.md +++ /dev/null @@ -1,15 +0,0 @@ -``` -% pandoc -f latex -\SI{+33.3}{\m} - -\num{+5} - -\SI{-33.3}{\m} - -\num{-33} -^D -

33.3 m

-

5

-

-33.3 m

-

-33

-``` -- cgit v1.2.3