git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Support siunitx `\ang`.

See #6658.

commit321658fe4dc21476f240e2405daf8fcec22447b9 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 2 Sep 2020, 16:14 (6 years ago) parent16c44cd
2 files changed+13
src/Text/Pandoc/Readers/LaTeX.hs+1 src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+12
src/Text/Pandoc/Readers/LaTeX.hs+1
@@ -881,6 +881,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
881881 , ("SI", doSI tok)
882882 , ("SIrange", doSIrange tok)
883883 , ("num", doSInum)
884+ , ("ang", doSIang)
884885 -- hyphenat
885886 , ("bshyp", lit "\\\173")
886887 , ("fshyp", lit "/\173")
src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+12
@@ -4,6 +4,7 @@ module Text.Pandoc.Readers.LaTeX.SIunitx
44 , doSI
55 , doSIrange
66 , doSInum
7+ , doSIang
78 )
89where
910import Text.Pandoc.Builder
@@ -65,6 +66,17 @@ parseNumPart =
6566 <$> (char 'e' *> parseDecimalNum)
6667 parseSpace = mempty <$ skipMany1 (char ' ')
6768
69+doSIang :: PandocMonad m => LP m Inlines
70+doSIang = do
71+ skipopts
72+ ps <- T.splitOn ";" . untokenize <$> braced
73+ case ps ++ repeat "" of
74+ (d:m:s:_) -> return $
75+ (if T.null d then mempty else (str d <> str "\xb0")) <>
76+ (if T.null m then mempty else (str m <> str "\x2032")) <>
77+ (if T.null s then mempty else (str s <> str "\x2033"))
78+ _ -> return mempty
79+
6880-- converts e.g. \SIrange{100}{200}{\ms} to "100 ms--200 ms"
6981doSIrange :: PandocMonad m => LP m Inlines -> LP m Inlines
7082doSIrange tok = do