git.iko.soy/typeable/pandoc
on master help sign in
Change T.P.Readers.LaTeX.SIunitx to export a command map...

instead of individual commands.

commit6a6291d9e3c1ce9c3453318d87239b6f9260d924 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 28 Feb 2021, 23:05 (6 years ago) parent12b4765
2 files changed+16−16
src/Text/Pandoc/Readers/LaTeX.hs+2−9 src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+14−7
src/Text/Pandoc/Readers/LaTeX.hs+2−9
@@ -62,7 +62,7 @@ import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
6262import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
6363import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
6464 babelLangToBCP47, setDefaultLanguage)
65−import Text.Pandoc.Readers.LaTeX.SIunitx
65+import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
6666import Text.Pandoc.Shared
6767import qualified Text.Pandoc.Translations as Translations
6868import Text.Pandoc.Walk
@@ -426,6 +426,7 @@ inlineCommands =
426426 M.union inlineLanguageCommands $
427427 M.union (accentCommands tok) $
428428 M.union (citationCommands inline) $
429+ M.union (siunitxCommands tok) $
429430 M.fromList
430431 [ ("emph", extractSpaces emph <$> tok)
431432 , ("textit", extractSpaces emph <$> tok)
@@ -594,14 +595,6 @@ inlineCommands =
594595 , ("Acfp", doAcronymPlural "full")
595596 , ("Acsp", doAcronymPlural "abbrv")
596597 , ("Aclp", doAcronymPlural "long")
597− -- siuntix
598− , ("si", skipopts *> dosi tok)
599− , ("SI", doSI tok)
600− , ("SIrange", doSIrange True tok)
601− , ("numrange", doSIrange False tok)
602− , ("numlist", doSInumlist)
603− , ("num", doSInum)
604− , ("ang", doSIang)
605598 -- hyphenat
606599 , ("bshyp", lit "\\\173")
607600 , ("fshyp", lit "/\173")
src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+14−7
@@ -1,12 +1,6 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Text.Pandoc.Readers.LaTeX.SIunitx
3− ( dosi
4− , doSI
5− , doSIrange
6− , doSInum
7− , doSInumlist
8− , doSIang
9− )
3+ ( siunitxCommands )
104where
115import Text.Pandoc.Builder
126import Text.Pandoc.Readers.LaTeX.Parsing
@@ -21,6 +15,19 @@ import Data.Text (Text)
2115import qualified Data.Text as T
2216import Data.List (intersperse)
2317
18+
19+siunitxCommands :: PandocMonad m
20+ => LP m Inlines -> M.Map Text (LP m Inlines)
21+siunitxCommands tok = M.fromList
22+ [ ("si", skipopts *> dosi tok)
23+ , ("SI", doSI tok)
24+ , ("SIrange", doSIrange True tok)
25+ , ("numrange", doSIrange False tok)
26+ , ("numlist", doSInumlist)
27+ , ("num", doSInum)
28+ , ("ang", doSIang)
29+ ]
30+
2431dosi :: PandocMonad m => LP m Inlines -> LP m Inlines
2532dosi tok = grouped (siUnit tok) <|> siUnit tok
2633