mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 05:43:39 +08:00
@@ -881,6 +881,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
|
||||
, ("SI", doSI tok)
|
||||
, ("SIrange", doSIrange tok)
|
||||
, ("num", doSInum)
|
||||
, ("ang", doSIang)
|
||||
-- hyphenat
|
||||
, ("bshyp", lit "\\\173")
|
||||
, ("fshyp", lit "/\173")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user