From 8f75a535429abdd8bd089f83a04a783baa60ce31 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Tue, 3 Nov 2020 10:25:56 -0800
Subject: [PATCH] Properly support optional cite argument for `\blockquote`.

(LaTeX reader)

Closes #6802.
---
 src/Text/Pandoc/Readers/LaTeX.hs | 15 ++++++++-------
 test/command/6802.md             |  9 +++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)
 create mode 100644 test/command/6802.md

diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 8e73af4ae..5e46caedb 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -309,18 +309,19 @@ enquote starred mblang = do
      else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok
 
 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
+blockquote cvariant mblang = do
+  citepar <- if cvariant
+                then (\xs -> para (cite xs mempty))
+                       <$> cites NormalCitation False
+                else option mempty $ para <$> bracketed inline
   let lang = mblang >>= babelLangToBCP47
   let langdiv = case lang of
                       Nothing -> id
                       Just l  -> divWith ("",[],[("lang", renderLang l)])
+  _closingPunct <- option mempty $ bracketed inline -- currently ignored
   bs <- grouped block
-  return $ blockQuote . langdiv $ (bs <> citePar)
+  optional $ symbolIn (".:;?!" :: [Char])  -- currently ignored
+  return $ blockQuote . langdiv $ (bs <> citepar)
 
 doAcronym :: PandocMonad m => Text -> LP m Inlines
 doAcronym form = do
diff --git a/test/command/6802.md b/test/command/6802.md
new file mode 100644
index 000000000..8f56f0e43
--- /dev/null
+++ b/test/command/6802.md
@@ -0,0 +1,9 @@
+```
+% pandoc -f latex -t native
+\blockquote[test][]{quote}
+^D
+[BlockQuote
+ [Para [Str "quote"]
+ ,Para [Str "test"]]]
+
+```