git.iko.soy/typeable/pandoc
on master help sign in
Change T.P.Readers.LaTeX.SIunitx to export a command map...
6a6291dJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+2−9
@@ -62,7 +62,7 @@ import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
62import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
62import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
63import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
63import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
64 babelLangToBCP47, setDefaultLanguage)
64 babelLangToBCP47, setDefaultLanguage)
65−import Text.Pandoc.Readers.LaTeX.SIunitx
65+import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
66import Text.Pandoc.Shared
66import Text.Pandoc.Shared
67import qualified Text.Pandoc.Translations as Translations
67import qualified Text.Pandoc.Translations as Translations
68import Text.Pandoc.Walk
68import Text.Pandoc.Walk
@@ -426,6 +426,7 @@ inlineCommands =
426 M.union inlineLanguageCommands $
426 M.union inlineLanguageCommands $
427 M.union (accentCommands tok) $
427 M.union (accentCommands tok) $
428 M.union (citationCommands inline) $
428 M.union (citationCommands inline) $
429+ M.union (siunitxCommands tok) $
429 M.fromList
430 M.fromList
430 [ ("emph", extractSpaces emph <$> tok)
431 [ ("emph", extractSpaces emph <$> tok)
431 , ("textit", extractSpaces emph <$> tok)
432 , ("textit", extractSpaces emph <$> tok)
@@ -594,14 +595,6 @@ inlineCommands =
594 , ("Acfp", doAcronymPlural "full")
595 , ("Acfp", doAcronymPlural "full")
595 , ("Acsp", doAcronymPlural "abbrv")
596 , ("Acsp", doAcronymPlural "abbrv")
596 , ("Aclp", doAcronymPlural "long")
597 , ("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)
605 -- hyphenat
598 -- hyphenat
606 , ("bshyp", lit "\\\173")
599 , ("bshyp", lit "\\\173")
607 , ("fshyp", lit "/\173")
600 , ("fshyp", lit "/\173")
src/Text/Pandoc/Readers/LaTeX/SIunitx.hs+14−7
@@ -1,12 +1,6 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2module Text.Pandoc.Readers.LaTeX.SIunitx
2module Text.Pandoc.Readers.LaTeX.SIunitx
3− ( dosi
3+ ( siunitxCommands )
4− , doSI
5− , doSIrange
6− , doSInum
7− , doSInumlist
8− , doSIang
9− )
10where
4where
11import Text.Pandoc.Builder
5import Text.Pandoc.Builder
12import Text.Pandoc.Readers.LaTeX.Parsing
6import Text.Pandoc.Readers.LaTeX.Parsing
@@ -21,6 +15,19 @@ import Data.Text (Text)
21import qualified Data.Text as T
15import qualified Data.Text as T
22import Data.List (intersperse)
16import Data.List (intersperse)
23
17
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+
24dosi :: PandocMonad m => LP m Inlines -> LP m Inlines
31dosi :: PandocMonad m => LP m Inlines -> LP m Inlines
25dosi tok = grouped (siUnit tok) <|> siUnit tok
32dosi tok = grouped (siUnit tok) <|> siUnit tok
26
33