Muse reader: use getIndent in parseHtmlContent

This commit is contained in:
Alexander Krotov 2018-10-05 18:47:45 +03:00
parent 659cce8442
commit 131dcff71d

View file

@ -169,6 +169,10 @@ firstColumn = getPosition >>= \pos -> guard (sourceColumn pos == 1)
eol :: Stream s m Char => ParserT s st m ()
eol = void newline <|> eof
getIndent :: PandocMonad m
=> MuseParser m Int
getIndent = subtract 1 . sourceColumn <$ many spaceChar <*> getPosition
someUntil :: (Stream s m t)
=> ParserT s u m a
-> ParserT s u m b
@ -202,11 +206,10 @@ parseHtmlContent :: PandocMonad m
=> String -- ^ Tag name
-> MuseParser m (Attr, F Blocks)
parseHtmlContent tag = try $ do
many spaceChar
pos <- getPosition
indent <- getIndent
attr <- openTag tag
manyTill spaceChar eol
content <- parseBlocksTill $ try $ count (sourceColumn pos - 1) spaceChar *> closeTag tag
content <- parseBlocksTill $ try $ count indent spaceChar *> closeTag tag
manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline
return (htmlAttrToPandoc attr, content)
@ -548,10 +551,6 @@ lineBlock = try $ do
-- *** List parsers
getIndent :: PandocMonad m
=> MuseParser m Int
getIndent = subtract 1 . sourceColumn <$ many spaceChar <*> getPosition
bulletListItemsUntil :: PandocMonad m
=> Int -- ^ Indentation
-> MuseParser m a -- ^ Terminator parser