diff options
author | Emerson Harkin <emerson.f.harkin@gmail.com> | 2020-07-23 19:47:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-23 16:47:32 -0700 |
commit | 1b8f1611983706f81cc33db4c4fe0ce379973c65 (patch) | |
tree | 1e90c52e927870084fefd1bdc3868267d5fcf22b /src | |
parent | c37a56e0606e796f60077cd3fca5494bfebf2186 (diff) | |
download | pandoc-1b8f1611983706f81cc33db4c4fe0ce379973c65.tar.gz |
Minimal support for SIRange in LaTeX reader (#6418)
Add support for `\SIRange{firstnumber}{secondnumber}{unit}` provided by siunitx.
An en-dash is used instead of localized "to".
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 24 |
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") |