git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: allow <quote> and other tags to be indented
a7ac590Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+3−2
@@ -153,6 +153,7 @@ htmlElement tag = try $ do
153
153
154htmlBlock :: PandocMonad m => String -> MuseParser m (Attr, String)
154htmlBlock :: PandocMonad m => String -> MuseParser m (Attr, String)
155htmlBlock tag = try $ do
155htmlBlock tag = try $ do
156+ many spaceChar
156 res <- htmlElement tag
157 res <- htmlElement tag
157 manyTill spaceChar eol
158 manyTill spaceChar eol
158 return res
159 return res
@@ -166,7 +167,8 @@ htmlAttrToPandoc attrs = (ident, classes, keyvals)
166
167
167parseHtmlContent :: PandocMonad m
168parseHtmlContent :: PandocMonad m
168 => String -> MuseParser m (Attr, F Blocks)
169 => String -> MuseParser m (Attr, F Blocks)
169−parseHtmlContent tag = do
170+parseHtmlContent tag = try $ do
171+ many spaceChar
170 (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
172 (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
171 manyTill spaceChar eol
173 manyTill spaceChar eol
172 content <- parseBlocksTill (manyTill spaceChar endtag)
174 content <- parseBlocksTill (manyTill spaceChar endtag)
@@ -398,7 +400,6 @@ dropSpacePrefix lns =
398
400
399exampleTag :: PandocMonad m => MuseParser m (F Blocks)
401exampleTag :: PandocMonad m => MuseParser m (F Blocks)
400exampleTag = try $ do
402exampleTag = try $ do
401− many spaceChar
402 (attr, contents) <- htmlBlock "example"
403 (attr, contents) <- htmlBlock "example"
403 return $ return $ B.codeBlockWith attr $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop contents
404 return $ return $ B.codeBlockWith attr $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop contents
404
405
test/Tests/Readers/Muse.hs+6
@@ -328,6 +328,12 @@ tests =
328 , "</quote>"
328 , "</quote>"
329 ] =?>
329 ] =?>
330 blockQuote (para "foo" <> blockQuote (para "bar") <> para "baz")
330 blockQuote (para "foo" <> blockQuote (para "bar") <> para "baz")
331+ , "Indented quote inside list" =:
332+ T.unlines [ " - <quote>"
333+ , " foo"
334+ , " </quote>"
335+ ] =?>
336+ bulletList [ blockQuote (para "foo") ]
331 , "Verse tag" =:
337 , "Verse tag" =:
332 T.unlines [ "<verse>"
338 T.unlines [ "<verse>"
333 , ""
339 , ""