aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-09-02 16:14:32 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-09-02 16:16:06 -0700
commit321658fe4dc21476f240e2405daf8fcec22447b9 (patch)
tree887ce1df6e4056ad9382eee0069720ee58fcadc3 /src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
parent16c44cd2a9a98c15e746d35e6ce6f66bd820fb24 (diff)
downloadpandoc-321658fe4dc21476f240e2405daf8fcec22447b9.tar.gz
LaTeX reader: Support siunitx `\ang`.
See #6658.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX/SIunitx.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/SIunitx.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
index f2b88f88b..cb60efba4 100644
--- a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
@@ -4,6 +4,7 @@ module Text.Pandoc.Readers.LaTeX.SIunitx
, doSI
, doSIrange
, doSInum
+ , doSIang
)
where
import Text.Pandoc.Builder
@@ -65,6 +66,17 @@ parseNumPart =
<$> (char 'e' *> parseDecimalNum)
parseSpace = mempty <$ skipMany1 (char ' ')
+doSIang :: PandocMonad m => LP m Inlines
+doSIang = do
+ skipopts
+ ps <- T.splitOn ";" . untokenize <$> braced
+ case ps ++ repeat "" of
+ (d:m:s:_) -> return $
+ (if T.null d then mempty else (str d <> str "\xb0")) <>
+ (if T.null m then mempty else (str m <> str "\x2032")) <>
+ (if T.null s then mempty else (str s <> str "\x2033"))
+ _ -> return mempty
+
-- converts e.g. \SIrange{100}{200}{\ms} to "100 ms--200 ms"
doSIrange :: PandocMonad m => LP m Inlines -> LP m Inlines
doSIrange tok = do