git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: fix reading of lists inside tags (#3802)
commit335a1c7f4867f7cd3575f07b5efa75712d59d1ac authorAlexander Krotov <ilabdsf@gmail.com> dateFri 21 Jul 2017, 11:04 (9 years ago) parent7191fe1
2 files changed+30−3
src/Text/Pandoc/Readers/Muse.hs+2−3 test/Tests/Readers/Muse.hs+28
src/Text/Pandoc/Readers/Muse.hs+2−3
@@ -115,11 +115,10 @@ htmlElement :: PandocMonad m => String -> MuseParser m (Attr, String)
115115htmlElement tag = try $ do
116116 (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
117117 content <- manyTill anyChar (endtag <|> endofinput)
118− return (htmlAttrToPandoc attr, trim content)
118+ return (htmlAttrToPandoc attr, content)
119119 where
120120 endtag = void $ htmlTag (~== TagClose tag)
121121 endofinput = lookAhead $ try $ skipMany blankline >> skipSpaces >> eof
122− trim = dropWhile (=='\n') . reverse . dropWhile (=='\n') . reverse
123122
124123htmlAttrToPandoc :: [Attribute String] -> Attr
125124htmlAttrToPandoc attrs = (ident, classes, keyvals)
@@ -132,7 +131,7 @@ parseHtmlContentWithAttrs :: PandocMonad m
132131 => String -> MuseParser m a -> MuseParser m (Attr, [a])
133132parseHtmlContentWithAttrs tag parser = do
134133 (attr, content) <- htmlElement tag
135− parsedContent <- try $ parseContent content
134+ parsedContent <- try $ parseContent (content ++ "\n")
136135 return (attr, parsedContent)
137136 where
138137 parseContent = parseFromString $ nested $ manyTill parser endOfContent
test/Tests/Readers/Muse.hs+28
@@ -314,5 +314,33 @@ tests =
314314 , para "* Bar"
315315 ]
316316 ]
317+ , "List inside a tag" =:
318+ T.unlines
319+ [ "<quote>"
320+ , " 1. First"
321+ , ""
322+ , " 2. Second"
323+ , ""
324+ , " 3. Third"
325+ , "</quote>"
326+ ] =?>
327+ blockQuote (orderedListWith (1, Decimal, Period) [ para "First"
328+ , para "Second"
329+ , para "Third"
330+ ])
331+ -- Amusewiki requires block tags to be on separate lines,
332+ -- but Emacs Muse allows them to be on the same line as contents.
333+ , "List inside an inline tag" =:
334+ T.unlines
335+ [ "<quote> 1. First"
336+ , ""
337+ , " 2. Second"
338+ , ""
339+ , " 3. Third</quote>"
340+ ] =?>
341+ blockQuote (orderedListWith (1, Decimal, Period) [ para "First"
342+ , para "Second"
343+ , para "Third"
344+ ])
317345 ]
318346 ]