aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 1c6954279..af00813b6 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -259,6 +259,29 @@ dosiunitx = do
emptyOr160 unit,
unit]
+-- converts e.g. \SIRange{100}{200}{\ms} to "100 ms--200 ms"
+doSIRange :: PandocMonad m => LP m Inlines
+doSIRange = do
+ skipopts
+ startvalue <- tok
+ startvalueprefix <- option "" $ bracketed tok
+ stopvalue <- tok
+ stopvalueprefix <- option "" $ bracketed tok
+ unit <- grouped (mconcat <$> many1 siUnit) <|> siUnit <|> tok
+ let emptyOr160 "" = ""
+ emptyOr160 _ = "\160"
+ return . mconcat $ [startvalueprefix,
+ emptyOr160 startvalueprefix,
+ startvalue,
+ emptyOr160 unit,
+ unit,
+ "\8211", -- An en-dash
+ stopvalueprefix,
+ emptyOr160 stopvalueprefix,
+ stopvalue,
+ emptyOr160 unit,
+ unit]
+
siUnit :: PandocMonad m => LP m Inlines
siUnit = do
Tok _ (CtrlSeq name) _ <- anyControlSeq
@@ -1075,6 +1098,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
, ("acsp", doAcronymPlural "abbrv")
-- siuntix
, ("SI", dosiunitx)
+ , ("SIRange", doSIRange)
-- hyphenat
, ("bshyp", lit "\\\173")
, ("fshyp", lit "/\173")