diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-08-21 17:39:27 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-08-21 17:39:27 -0700 |
commit | a733068ebf4b9dea2769c5698a4d46e6e5918bf1 (patch) | |
tree | b1394729229209e82cf168f0f414f68c8379e5db /src/Text/Pandoc | |
parent | fb3295cb9e54260b5395afde669aa2a14334592b (diff) | |
download | pandoc-a733068ebf4b9dea2769c5698a4d46e6e5918bf1.tar.gz |
LaTeX reader: support enquote*, foreignquote, hypphenquote...
from csquotes. See #4848. Still TBD: blockquote, blockcquote,
foreignblockquote.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 2f16738ac..cd21179df 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -975,13 +975,22 @@ quoted' f starter ender = do cs -> cs) else lit startchs -enquote :: PandocMonad m => LP m Inlines -enquote = do +enquote :: PandocMonad m => Bool -> Maybe Text -> LP m Inlines +enquote starred mblang = do skipopts + let lang = (T.unpack <$> mblang) >>= babelLangToBCP47 + let langspan = case lang of + Nothing -> id + Just l -> spanWith ("",[],[("lang", renderLang l)]) quoteContext <- sQuoteContext <$> getState - if quoteContext == InDoubleQuote - then singleQuoted <$> withQuoteContext InSingleQuote tok - else doubleQuoted <$> withQuoteContext InDoubleQuote tok + if starred || quoteContext == InDoubleQuote + then singleQuoted . langspan <$> withQuoteContext InSingleQuote tok + else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok + +blockquote :: PandocMonad m => LP m Blocks +blockquote = do + bs <- grouped block + return $ blockQuote bs doAcronym :: PandocMonad m => String -> LP m Inlines doAcronym form = do @@ -1769,7 +1778,14 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList src <- unescapeURL . T.unpack . removeDoubleQuotes . untokenize <$> braced mkImage options src) - , ("enquote", enquote) + , ("enquote*", enquote True Nothing) + , ("enquote", enquote False Nothing) + -- foreignquote is supposed to use native quote marks + , ("foreignquote*", braced >>= enquote True . Just . untokenize) + , ("foreignquote", braced >>= enquote False . Just . untokenize) + -- hypehnquote uses regular quotes + , ("hyphenquote*", braced >>= enquote True . Just . untokenize) + , ("hyphenquote", braced >>= enquote False . Just . untokenize) , ("figurename", doTerm Translations.Figure) , ("prefacename", doTerm Translations.Preface) , ("refname", doTerm Translations.References) @@ -2524,6 +2540,8 @@ blockCommands = M.fromList -- LaTeX colors , ("textcolor", coloredBlock "color") , ("colorbox", coloredBlock "background-color") + -- csquotse + , ("blockquote", blockquote) -- include , ("include", include "include") , ("input", include "input") |