From 685788cd4b13d2162dc011e8f3826da37522e59b Mon Sep 17 00:00:00 2001
From: bucklereed <horridimpfoobarbaz@chammy.info>
Date: Sat, 5 Aug 2017 18:03:31 +0100
Subject: [PATCH] LaTeX reader: plainbreak, fancybreak et al from the memoir
 class (#3833)

---
 src/Text/Pandoc/Readers/LaTeX.hs |  9 +++++++++
 test/Tests/Readers/LaTeX.hs      | 26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 5877bbbe1..b06cd7348 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1701,6 +1701,15 @@ blockCommands = M.fromList $
    -- letters
    , ("opening", (para . trimInlines) <$> (skipopts *> tok))
    , ("closing", skipopts *> closing)
+   -- memoir
+   , ("plainbreak", braced >> pure horizontalRule)
+   , ("plainbreak*", braced >> pure horizontalRule)
+   , ("fancybreak", braced >> pure horizontalRule)
+   , ("fancybreak*", braced >> pure horizontalRule)
+   , ("plainfancybreak", braced >> braced >> braced >> pure horizontalRule)
+   , ("plainfancybreak*", braced >> braced >> braced >> pure horizontalRule)
+   , ("pfbreak", pure horizontalRule)
+   , ("pfbreak*", pure horizontalRule)
    --
    , ("hrule", pure horizontalRule)
    , ("strut", pure mempty)
diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs
index f2be6de5f..b07eb875a 100644
--- a/test/Tests/Readers/LaTeX.hs
+++ b/test/Tests/Readers/LaTeX.hs
@@ -117,6 +117,32 @@ tests = [ testGroup "basic"
             mconcat ["^^" <> T.pack [i] | i <- hex] =?>
             para (str $ ['p'..'y']++['!'..'&'])
           ]
+        , testGroup "memoir scene breaks"
+          [ "plainbreak" =:
+            "hello\\plainbreak{2}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "plainbreak*" =:
+            "hello\\plainbreak*{2}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "fancybreak" =:
+            "hello\\fancybreak{b r e a k}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "fancybreak*" =:
+            "hello\\fancybreak*{b r e a k}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "plainfancybreak" =:
+            "hello\\plainfancybreak{4}{2}{b r e a k}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "plainfancybreak*" =:
+            "hello\\plainfancybreak*{4}{2}{b r e a k}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "pfbreak" =:
+            "hello\\pfbreak{}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          , "pfbreak*" =:
+            "hello\\pfbreak*{}goodbye" =?>
+            para (str "hello") <> horizontalRule <> para (str "goodbye")
+          ]
         ]
 
 baseCitation :: Citation