git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Support siunitx `\ang`.
321658fJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+1
@@ -881,6 +881,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
881 , ("SI", doSI tok)
881 , ("SI", doSI tok)
882 , ("SIrange", doSIrange tok)
882 , ("SIrange", doSIrange tok)
883 , ("num", doSInum)
883 , ("num", doSInum)
884+ , ("ang", doSIang)
884 -- hyphenat
885 -- hyphenat
885 , ("bshyp", lit "\\\173")
886 , ("bshyp", lit "\\\173")
886 , ("fshyp", lit "/\173")
887 , ("fshyp", lit "/\173")
src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+12
@@ -4,6 +4,7 @@ module Text.Pandoc.Readers.LaTeX.SIunitx
4 , doSI
4 , doSI
5 , doSIrange
5 , doSIrange
6 , doSInum
6 , doSInum
7+ , doSIang
7 )
8 )
8where
9where
9import Text.Pandoc.Builder
10import Text.Pandoc.Builder
@@ -65,6 +66,17 @@ parseNumPart =
65 <$> (char 'e' *> parseDecimalNum)
66 <$> (char 'e' *> parseDecimalNum)
66 parseSpace = mempty <$ skipMany1 (char ' ')
67 parseSpace = mempty <$ skipMany1 (char ' ')
67
68
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+
68-- converts e.g. \SIrange{100}{200}{\ms} to "100 ms--200 ms"
80-- converts e.g. \SIrange{100}{200}{\ms} to "100 ms--200 ms"
69doSIrange :: PandocMonad m => LP m Inlines -> LP m Inlines
81doSIrange :: PandocMonad m => LP m Inlines -> LP m Inlines
70doSIrange tok = do
82doSIrange tok = do