diff options
author | schrieveslaach <schrieveslaach@online.de> | 2017-08-16 19:24:46 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-08-16 10:24:46 -0700 |
commit | cf4b40162d10b17cc7e8fade36c6d2ca9903d9dd (patch) | |
tree | 55dbe2d65d9f2933fff73b38c48f1f23d8dac57d /src/Text | |
parent | 708bb8afe48e82fd35b1951714ecef1304eb38f7 (diff) | |
download | pandoc-cf4b40162d10b17cc7e8fade36c6d2ca9903d9dd.tar.gz |
LaTeX reader: add Support for `glossaries` and `acronym` package (#3589)
Acronyms are not resolved by the reader, but acronym and glossary information is put into attributes on Spans so that they can be processed in filters.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 986547f42..5627e4ee1 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -702,6 +702,21 @@ enquote = do then singleQuoted <$> withQuoteContext InSingleQuote tok else doubleQuoted <$> withQuoteContext InDoubleQuote tok +doAcronym :: PandocMonad m => String -> LP m Inlines +doAcronym form = do + acro <- braced + return . mconcat $ [spanWith ("",[],[("acronym-label", toksToString acro), + ("acronym-form", "singular+" ++ form)]) + $ str $ toksToString acro] + +doAcronymPlural :: PandocMonad m => String -> LP m Inlines +doAcronymPlural form = do + acro <- braced + plural <- lit "s" + return . mconcat $ [spanWith ("",[],[("acronym-label", toksToString acro), + ("acronym-form", "plural+" ++ form)]) $ mconcat + $ [str $ toksToString acro, plural]] + doverb :: PandocMonad m => LP m Inlines doverb = do Tok _ Symbol t <- anySymbol @@ -1371,6 +1386,30 @@ inlineCommands = M.fromList $ , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>= addMeta "nocite")) , ("hypertarget", braced >> tok) + -- glossaries package + , ("gls", doAcronym "short") + , ("Gls", doAcronym "short") + , ("glsdesc", doAcronym "long") + , ("Glsdesc", doAcronym "long") + , ("GLSdesc", doAcronym "long") + , ("acrlong", doAcronym "long") + , ("Acrlong", doAcronym "long") + , ("acrfull", doAcronym "full") + , ("Acrfull", doAcronym "full") + , ("acrshort", doAcronym "abbrv") + , ("Acrshort", doAcronym "abbrv") + , ("glspl", doAcronymPlural "short") + , ("Glspl", doAcronymPlural "short") + , ("glsdescplural", doAcronymPlural "long") + , ("Glsdescplural", doAcronymPlural "long") + , ("GLSdescplural", doAcronymPlural "long") + -- acronyms package + , ("ac", doAcronym "short") + , ("acf", doAcronym "full") + , ("acs", doAcronym "abbrv") + , ("acp", doAcronymPlural "short") + , ("acfp", doAcronymPlural "full") + , ("acsp", doAcronymPlural "abbrv") -- siuntix , ("SI", dosiunitx) -- hyphenat |