aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2017-06-28 15:32:53 +0300
committerJohn MacFarlane <jgm@berkeley.edu>2017-06-28 14:32:53 +0200
commit79cc56726c7e876314c7c21f5bb5f65084e7d8b7 (patch)
tree1632cc2847edbb81f36a93778046bd0a4b87fbef /src/Text/Pandoc
parentcd690d04015431e89feefa7f68e9609efab1f16b (diff)
downloadpandoc-79cc56726c7e876314c7c21f5bb5f65084e7d8b7.tar.gz
Muse reader: parse indented blockquotes (#3769)
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index eb0769e0b..a51306347 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -187,6 +187,7 @@ blockElements = choice [ comment
, orderedList
, table
, commentTag
+ , indentedBlock
, noteBlock
]
@@ -209,7 +210,8 @@ separator = try $ do
header :: PandocMonad m => MuseParser m (F Blocks)
header = try $ do
st <- stateParserContext <$> getState
- getPosition >>= \pos -> guard (st == NullState && sourceColumn pos == 1)
+ q <- stateQuoteContext <$> getState
+ getPosition >>= \pos -> guard (st == NullState && q == NoQuote && sourceColumn pos == 1)
level <- liftM length $ many1 $ char '*'
guard $ level <= 5
skipSpaces
@@ -248,6 +250,25 @@ quoteTag = blockTag B.blockQuote "quote"
commentTag :: PandocMonad m => MuseParser m (F Blocks)
commentTag = parseHtmlContent "comment" block >> return mempty
+-- Indented block is either center, right or quote
+indentedLine :: PandocMonad m => MuseParser m (Int, String)
+indentedLine = try $ do
+ indent <- length <$> many1 spaceChar
+ line <- anyLine
+ return (indent, line)
+
+rawIndentedBlock :: PandocMonad m => MuseParser m (Int, String)
+rawIndentedBlock = try $ do
+ lns <- many1 indentedLine
+ let indent = minimum $ map fst lns
+ return (indent, unlines $ map snd lns)
+
+indentedBlock :: PandocMonad m => MuseParser m (F Blocks)
+indentedBlock = try $ do
+ (indent, raw) <- rawIndentedBlock
+ contents <- withQuoteContext InDoubleQuote $ parseFromString parseBlocks raw
+ return $ (if indent >= 2 && indent < 6 then B.blockQuote else id) <$> contents
+
para :: PandocMonad m => MuseParser m (F Blocks)
para = liftM B.para . trimInlinesF . mconcat <$> many1Till inline endOfParaElement
where