git.iko.soy/typeable/pandoc
on master help sign in
Some attempts to fix the issue.
commit3e57a0d2b709cd3559bc199c58f2cdf3155b9e25 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 6 Mar 2019, 09:53 (8 years ago) parent7b63cce
1 file changed+16−13
src/Text/Pandoc/Readers/Markdown.hs+16−13
src/Text/Pandoc/Readers/Markdown.hs+16−13
@@ -1089,7 +1089,13 @@ htmlBlock :: PandocMonad m => MarkdownParser m (F Blocks)
10891089htmlBlock = do
10901090 guardEnabled Ext_raw_html
10911091 try (do
1092− (TagOpen _ attrs) <- lookAhead $ fst <$> htmlTag isBlockTag
1092+ inHtmlBlock <- stateInHtmlBlock <$> getState
1093+ case inHtmlBlock of
1094+ Just "div" -> (guardDisabled Ext_native_divs >> skipMany spaceChar)
1095+ <|> return ()
1096+ Just _ -> skipMany spaceChar
1097+ Nothing -> return ()
1098+ TagOpen _ attrs <- lookAhead $ fst <$> htmlTag isBlockTag
10931099 (return . B.rawBlock "html") <$> rawVerbatimBlock
10941100 <|> (do guardEnabled Ext_markdown_attribute
10951101 oldMarkdownAttribute <- stateMarkdownAttribute <$> getState
@@ -1148,25 +1154,22 @@ rawHtmlBlocks = do
11481154 (TagOpen tagtype _, raw) <- htmlTag isBlockTag
11491155 -- we don't want '<td> text' to be a code block:
11501156 skipMany spaceChar
1151− indentlevel <- (blankline >> length <$> many (char ' ')) <|> return 0
1157+ optional blankline
11521158 -- try to find closing tag
11531159 -- we set stateInHtmlBlock so that closing tags that can be either block or
11541160 -- inline will not be parsed as inline tags
11551161 oldInHtmlBlock <- stateInHtmlBlock <$> getState
11561162 updateState $ \st -> st{ stateInHtmlBlock = Just tagtype }
1157− let closer = htmlTag (\x -> x ~== TagClose tagtype)
1158− let block' = do notFollowedBy' closer
1159− gobbleAtMostSpaces indentlevel
1160− block
1163+ let closer = try $ skipMany spaceChar >> htmlTag (~== TagClose tagtype)
1164+ let block' = try $ do notFollowedBy' closer
1165+ block
11611166 contents <- mconcat <$> many block'
1162− result <-
1163− (closer >>= \(_, rawcloser) -> return (
1164− return (B.rawBlock "html" $ stripMarkdownAttribute raw) <>
1165− contents <>
1166− return (B.rawBlock "html" rawcloser)))
1167− <|> return (return (B.rawBlock "html" raw) <> contents)
1167+ rawcloser <- option mempty $ B.rawBlock "html" . snd <$> closer
11681168 updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
1169− return result
1169+ return $
1170+ return (B.rawBlock "html" (stripMarkdownAttribute raw)) <>
1171+ contents <>
1172+ return rawcloser
11701173
11711174-- remove markdown="1" attribute
11721175stripMarkdownAttribute :: String -> String