aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-08-21 21:01:52 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-21 21:03:43 -0700
commit3b5949e8f278a8d407777f567fdaf8e421323ced (patch)
treeb7203d45af30ef77c88c55f9ea02943b9e85d1dd
parent5823031796922f14ce9bbc913c8b453a66563ff5 (diff)
downloadpandoc-3b5949e8f278a8d407777f567fdaf8e421323ced.tar.gz
LaTeX reader: support blockcquote, foreignblockquote from csquotes.
Also foreigncblockquote, hyphenblockquote, hyphencblockquote. Closes #4848. But note: currently foreignquote will be parsed as a regular Quoted inline (not using the quotes appropriate to the foreign language).
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs24
-rw-r--r--test/command/4848.md7
2 files changed, 23 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index cd21179df..56f14752a 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -987,10 +987,19 @@ enquote starred mblang = do
then singleQuoted . langspan <$> withQuoteContext InSingleQuote tok
else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok
-blockquote :: PandocMonad m => LP m Blocks
-blockquote = do
+blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
+blockquote citations mblang = do
+ citePar <- if citations
+ then do
+ cs <- cites NormalCitation False
+ return $ para (cite cs mempty)
+ else return mempty
+ let lang = (T.unpack <$> mblang) >>= babelLangToBCP47
+ let langdiv = case lang of
+ Nothing -> id
+ Just l -> divWith ("",[],[("lang", renderLang l)])
bs <- grouped block
- return $ blockQuote bs
+ return $ blockQuote . langdiv $ (bs <> citePar)
doAcronym :: PandocMonad m => String -> LP m Inlines
doAcronym form = do
@@ -2540,8 +2549,13 @@ blockCommands = M.fromList
-- LaTeX colors
, ("textcolor", coloredBlock "color")
, ("colorbox", coloredBlock "background-color")
- -- csquotse
- , ("blockquote", blockquote)
+ -- csquotes
+ , ("blockquote", blockquote False Nothing)
+ , ("blockcquote", blockquote True Nothing)
+ , ("foreignblockquote", braced >>= blockquote False . Just . untokenize)
+ , ("foreignblockcquote", braced >>= blockquote True . Just . untokenize)
+ , ("hyphenblockquote", braced >>= blockquote False . Just . untokenize)
+ , ("hyphenblockcquote", braced >>= blockquote True . Just . untokenize)
-- include
, ("include", include "include")
, ("input", include "input")
diff --git a/test/command/4848.md b/test/command/4848.md
index 287bd9d33..2cd2bab34 100644
--- a/test/command/4848.md
+++ b/test/command/4848.md
@@ -39,7 +39,8 @@ consectetuer.
^D
[Para [Str "Lorem",Space,Str "ipsum"]
,BlockQuote
- [Para [Str "dolor",Space,Str "sit",Space,Str "amet",Space,Cite [Citation {citationId = "Knu86", citationPrefix = [], citationSuffix = [Str "198"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [RawInline (Format "latex") "\\cite[198]{Knu86}"]]]
+ [Para [Str "dolor",Space,Str "sit",Space,Str "amet"]
+ ,Para [Cite [Citation {citationId = "Knu86", citationPrefix = [], citationSuffix = [Str "198"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] []]]
,Para [Str "consectetuer."]]
```
@@ -50,8 +51,8 @@ Lorem ipsum
consectetuer.
^D
[Para [Str "Lorem",Space,Str "ipsum"]
-,Div ("",[],[("lang","it")])
- [BlockQuote
+,BlockQuote
+ [Div ("",[],[("lang","it")])
[Para [Str "dolor",Space,Str "sit",Space,Str "amet"]]]
,Para [Str "consectetuer."]]
```