git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: add Support for `glossaries` and `acronym` package (#3589)
cf4b401schrieveslaach
src/Text/Pandoc/Readers/LaTeX.hs+39
@@ -702,6 +702,21 @@ enquote = do
702 then singleQuoted <$> withQuoteContext InSingleQuote tok
702 then singleQuoted <$> withQuoteContext InSingleQuote tok
703 else doubleQuoted <$> withQuoteContext InDoubleQuote tok
703 else doubleQuoted <$> withQuoteContext InDoubleQuote tok
704
704
705+doAcronym :: PandocMonad m => String -> LP m Inlines
706+doAcronym form = do
707+ acro <- braced
708+ return . mconcat $ [spanWith ("",[],[("acronym-label", toksToString acro),
709+ ("acronym-form", "singular+" ++ form)])
710+ $ str $ toksToString acro]
711+
712+doAcronymPlural :: PandocMonad m => String -> LP m Inlines
713+doAcronymPlural form = do
714+ acro <- braced
715+ plural <- lit "s"
716+ return . mconcat $ [spanWith ("",[],[("acronym-label", toksToString acro),
717+ ("acronym-form", "plural+" ++ form)]) $ mconcat
718+ $ [str $ toksToString acro, plural]]
719+
705doverb :: PandocMonad m => LP m Inlines
720doverb :: PandocMonad m => LP m Inlines
706doverb = do
721doverb = do
707 Tok _ Symbol t <- anySymbol
722 Tok _ Symbol t <- anySymbol
@@ -1371,6 +1386,30 @@ inlineCommands = M.fromList $
1371 , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
1386 , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
1372 addMeta "nocite"))
1387 addMeta "nocite"))
1373 , ("hypertarget", braced >> tok)
1388 , ("hypertarget", braced >> tok)
1389+ -- glossaries package
1390+ , ("gls", doAcronym "short")
1391+ , ("Gls", doAcronym "short")
1392+ , ("glsdesc", doAcronym "long")
1393+ , ("Glsdesc", doAcronym "long")
1394+ , ("GLSdesc", doAcronym "long")
1395+ , ("acrlong", doAcronym "long")
1396+ , ("Acrlong", doAcronym "long")
1397+ , ("acrfull", doAcronym "full")
1398+ , ("Acrfull", doAcronym "full")
1399+ , ("acrshort", doAcronym "abbrv")
1400+ , ("Acrshort", doAcronym "abbrv")
1401+ , ("glspl", doAcronymPlural "short")
1402+ , ("Glspl", doAcronymPlural "short")
1403+ , ("glsdescplural", doAcronymPlural "long")
1404+ , ("Glsdescplural", doAcronymPlural "long")
1405+ , ("GLSdescplural", doAcronymPlural "long")
1406+ -- acronyms package
1407+ , ("ac", doAcronym "short")
1408+ , ("acf", doAcronym "full")
1409+ , ("acs", doAcronym "abbrv")
1410+ , ("acp", doAcronymPlural "short")
1411+ , ("acfp", doAcronymPlural "full")
1412+ , ("acsp", doAcronymPlural "abbrv")
1374 -- siuntix
1413 -- siuntix
1375 , ("SI", dosiunitx)
1414 , ("SI", dosiunitx)
1376 -- hyphenat
1415 -- hyphenat
test/command/3539.mdnew file+45
@@ -0,0 +1,45 @@
1+# Commands of [glossaries package](ftp://ftp.tu-chemnitz.de/pub/tex/macros/latex/contrib/glossaries/glossaries-code.pdf)
2+
3+```
4+% pandoc -f latex -t native
5+Many programming languages provide \glspl{API}. Each \gls{API} should provide a documentation.
6+^D
7+[Para [Str "Many",Space,Str "programming",Space,Str "languages",Space,Str "provide",Space,Span ("",[],[("acronym-label","API"),("acronym-form","plural+short")]) [Str "APIs"],Str ".",Space,Str "Each",Space,Span ("",[],[("acronym-label","API"),("acronym-form","singular+short")]) [Str "API"],Space,Str "should",Space,Str "provide",Space,Str "a",Space,Str "documentation."]]
8+```
9+
10+```
11+% pandoc -f latex -t native
12+\Glsdesc{API} XYZ ist not as performant as \glsdesc{API} ZXY.
13+^D
14+[Para [Span ("",[],[("acronym-label","API"),("acronym-form","singular+long")]) [Str "API"],Space,Str "XYZ",Space,Str "ist",Space,Str "not",Space,Str "as",Space,Str "performant",Space,Str "as",Space,Span ("",[],[("acronym-label","API"),("acronym-form","singular+long")]) [Str "API"],Space,Str "ZXY."]]
15+```
16+
17+```
18+% pandoc -f latex -t native
19+\Acrlong{API} XYZ ist not as performant as \acrlong{API} ZXY.
20+^D
21+[Para [Span ("",[],[("acronym-label","API"),("acronym-form","singular+long")]) [Str "API"],Space,Str "XYZ",Space,Str "ist",Space,Str "not",Space,Str "as",Space,Str "performant",Space,Str "as",Space,Span ("",[],[("acronym-label","API"),("acronym-form","singular+long")]) [Str "API"],Space,Str "ZXY."]]
22+```
23+
24+```
25+% pandoc -f latex -t native
26+\Acrfull{API} XYZ ist not as performant as \acrfull{API} ZXY.
27+^D
28+[Para [Span ("",[],[("acronym-label","API"),("acronym-form","singular+full")]) [Str "API"],Space,Str "XYZ",Space,Str "ist",Space,Str "not",Space,Str "as",Space,Str "performant",Space,Str "as",Space,Span ("",[],[("acronym-label","API"),("acronym-form","singular+full")]) [Str "API"],Space,Str "ZXY."]]
29+```
30+
31+```
32+% pandoc -f latex -t native
33+\Acrshort{API} XYZ ist not as performant as \acrshort{API} ZXY.
34+^D
35+[Para [Span ("",[],[("acronym-label","API"),("acronym-form","singular+abbrv")]) [Str "API"],Space,Str "XYZ",Space,Str "ist",Space,Str "not",Space,Str "as",Space,Str "performant",Space,Str "as",Space,Span ("",[],[("acronym-label","API"),("acronym-form","singular+abbrv")]) [Str "API"],Space,Str "ZXY."]]
36+```
37+
38+# Commands of [acronym package](ftp://ftp.mpi-sb.mpg.de/pub/tex/mirror/ftp.dante.de/pub/tex/macros/latex/contrib/acronym/acronym.pdf)
39+
40+```
41+% pandoc -f latex -t native
42+Many programming languages provide \acp{API}. Each \ac{API} should provide a documentation.
43+^D
44+[Para [Str "Many",Space,Str "programming",Space,Str "languages",Space,Str "provide",Space,Span ("",[],[("acronym-label","API"),("acronym-form","plural+short")]) [Str "APIs"],Str ".",Space,Str "Each",Space,Span ("",[],[("acronym-label","API"),("acronym-form","singular+short")]) [Str "API"],Space,Str "should",Space,Str "provide",Space,Str "a",Space,Str "documentation."]]
45+```