git.iko.soy/typeable/pandoc
on master help sign in
Add support to parse unit string of \SI command (closes #4296).
commit155a2ac0391e8b800d8d2ff0fb3ebe5e049ca278 authorMarc Schreiber <schrieveslaach@online.de> dateSun 18 Mar 2018, 04:59 (9 years ago) parent14cc82b
2 files changed+50−1
src/Text/Pandoc/Readers/LaTeX.hs+14−1 test/command/3587.md+36
src/Text/Pandoc/Readers/LaTeX.hs+14−1
@@ -666,7 +666,7 @@ dosiunitx = do
666666 skipopts
667667 value <- tok
668668 valueprefix <- option "" $ bracketed tok
669− unit <- tok
669+ unit <- inlineCommand' <|> tok
670670 let emptyOr160 "" = ""
671671 emptyOr160 _ = "\160"
672672 return . mconcat $ [valueprefix,
@@ -675,6 +675,12 @@ dosiunitx = do
675675 emptyOr160 unit,
676676 unit]
677677
678+-- siunitx's \square command
679+dosquare :: PandocMonad m => LP m Inlines
680+dosquare = do
681+ unit <- inlineCommand' <|> tok
682+ return . mconcat $ [unit, "\178"]
683+
678684lit :: String -> LP m Inlines
679685lit = pure . str
680686
@@ -1468,6 +1474,13 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
14681474 , ("acsp", doAcronymPlural "abbrv")
14691475 -- siuntix
14701476 , ("SI", dosiunitx)
1477+ -- units of siuntix
1478+ , ("celsius", lit "°C")
1479+ , ("degreeCelsius", lit "°C")
1480+ , ("gram", lit "g")
1481+ , ("meter", lit "m")
1482+ , ("milli", lit "m")
1483+ , ("square", dosquare)
14711484 -- hyphenat
14721485 , ("bshyp", lit "\\\173")
14731486 , ("fshyp", lit "/\173")
test/command/3587.md+36
@@ -19,3 +19,39 @@
1919^D
2020[Para [Str "{}\160{}\160{}"]]
2121```
22+
23+```
24+% pandoc -f latex -t native
25+\SI{30}{\milli\meter}
26+^D
27+[Para [Str "30\160mm"]]
28+```
29+
30+```
31+% pandoc -f latex -t native
32+\SI{6}{\gram}
33+^D
34+[Para [Str "6\160g"]]
35+```
36+
37+```
38+% pandoc -f latex -t native
39+\SI{25}{\square\meter}
40+^D
41+[Para [Str "25\160m\178"]]
42+```
43+
44+```
45+% pandoc -f latex -t native
46+\SI{18.2}{\degreeCelsius}
47+^D
48+[Para [Str "18.2\160\176C"]]
49+```
50+
51+```
52+% pandoc -f latex -t native
53+\SI{18.2}{\celsius}
54+^D
55+[Para [Str "18.2\160\176C"]]
56+```
57+