Muse reader: fix reading of lists inside tags (#3802)
This commit is contained in:
parent
7191fe1f29
commit
335a1c7f48
2 changed files with 30 additions and 3 deletions
|
@ -115,11 +115,10 @@ htmlElement :: PandocMonad m => String -> MuseParser m (Attr, String)
|
|||
htmlElement tag = try $ do
|
||||
(TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
|
||||
content <- manyTill anyChar (endtag <|> endofinput)
|
||||
return (htmlAttrToPandoc attr, trim content)
|
||||
return (htmlAttrToPandoc attr, content)
|
||||
where
|
||||
endtag = void $ htmlTag (~== TagClose tag)
|
||||
endofinput = lookAhead $ try $ skipMany blankline >> skipSpaces >> eof
|
||||
trim = dropWhile (=='\n') . reverse . dropWhile (=='\n') . reverse
|
||||
|
||||
htmlAttrToPandoc :: [Attribute String] -> Attr
|
||||
htmlAttrToPandoc attrs = (ident, classes, keyvals)
|
||||
|
@ -132,7 +131,7 @@ parseHtmlContentWithAttrs :: PandocMonad m
|
|||
=> String -> MuseParser m a -> MuseParser m (Attr, [a])
|
||||
parseHtmlContentWithAttrs tag parser = do
|
||||
(attr, content) <- htmlElement tag
|
||||
parsedContent <- try $ parseContent content
|
||||
parsedContent <- try $ parseContent (content ++ "\n")
|
||||
return (attr, parsedContent)
|
||||
where
|
||||
parseContent = parseFromString $ nested $ manyTill parser endOfContent
|
||||
|
|
|
@ -314,5 +314,33 @@ tests =
|
|||
, para "* Bar"
|
||||
]
|
||||
]
|
||||
, "List inside a tag" =:
|
||||
T.unlines
|
||||
[ "<quote>"
|
||||
, " 1. First"
|
||||
, ""
|
||||
, " 2. Second"
|
||||
, ""
|
||||
, " 3. Third"
|
||||
, "</quote>"
|
||||
] =?>
|
||||
blockQuote (orderedListWith (1, Decimal, Period) [ para "First"
|
||||
, para "Second"
|
||||
, para "Third"
|
||||
])
|
||||
-- Amusewiki requires block tags to be on separate lines,
|
||||
-- but Emacs Muse allows them to be on the same line as contents.
|
||||
, "List inside an inline tag" =:
|
||||
T.unlines
|
||||
[ "<quote> 1. First"
|
||||
, ""
|
||||
, " 2. Second"
|
||||
, ""
|
||||
, " 3. Third</quote>"
|
||||
] =?>
|
||||
blockQuote (orderedListWith (1, Decimal, Period) [ para "First"
|
||||
, para "Second"
|
||||
, para "Third"
|
||||
])
|
||||
]
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue