@@ -54,7 +54,7 @@ import Text.Pandoc.Parsing hiding ((<|>))
5454import Text.Pandoc.Walk
5555import qualified Data.Map as M
5656import Data.Foldable ( for_ )
57−import Data.Maybe ( fromMaybe, isJust)
57+import Data.Maybe ( fromMaybe, isJust, isNothing )
5858import Data.List ( intercalate, isPrefixOf )
5959import Data.Char ( isDigit, isLetter, isAlphaNum )
6060import Control.Monad ( guard, mzero, void, unless )
@@ -377,6 +377,7 @@ pDiv = try $ do
377377 guardEnabled Ext_native_divs
378378 let isDivLike "div" = True
379379 isDivLike "section" = True
380+ isDivLike "main" = True
380381 isDivLike _ = False
381382 TagOpen tag attr' <- lookAhead $ pSatisfy $ tagOpen isDivLike (const True)
382383 let attr = toStringAttr attr'
@@ -385,7 +386,10 @@ pDiv = try $ do
385386 let classes' = if tag == "section"
386387 then "section":classes
387388 else classes
388− return $ B.divWith (ident, classes', kvs) contents
389+ kvs' = if tag == "main" && isNothing (lookup "role" kvs)
390+ then ("role", "main"):kvs
391+ else kvs
392+ return $ B.divWith (ident, classes', kvs') contents
389393
390394pRawHtmlBlock :: PandocMonad m => TagParser m Blocks
391395pRawHtmlBlock = do
@@ -940,7 +944,7 @@ blockHtmlTags = Set.fromList
940944 "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure",
941945 "footer", "form", "h1", "h2", "h3", "h4",
942946 "h5", "h6", "head", "header", "hgroup", "hr", "html",
943− "isindex", "menu", "noframes", "ol", "output", "p", "pre",
947+ "isindex", "main", "menu", "noframes", "ol", "output", "p", "pre",
944948 "section", "table", "tbody", "textarea",
945949 "thead", "tfoot", "ul", "dd",
946950 "dt", "frameset", "li", "tbody", "td", "tfoot",
@@ -1022,10 +1026,10 @@ _ `closes` "html" = False
10221026"optgroup" `closes` "optgroup" = True
10231027"optgroup" `closes` "option" = True
10241028"option" `closes` "option" = True
1025−-- http://www.w3.org/TR/html-markup/p.html
1029+-- https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
10261030x `closes` "p" | x `elem` ["address", "article", "aside", "blockquote",
10271031 "dir", "div", "dl", "fieldset", "footer", "form", "h1", "h2", "h3", "h4",
1028− "h5", "h6", "header", "hr", "menu", "nav", "ol", "p", "pre", "section",
1032+ "h5", "h6", "header", "hr", "main", "menu", "nav", "ol", "p", "pre", "section",
10291033 "table", "ul"] = True
10301034"meta" `closes` "meta" = True
10311035"form" `closes` "form" = True
@@ -1038,8 +1042,8 @@ t `closes` "select" | t /= "option" = True
10381042"tfoot" `closes` t | t `elem` ["thead","colgroup"] = True
10391043"tbody" `closes` t | t `elem` ["tbody","tfoot","thead","colgroup"] = True
10401044t `closes` t2 |
1041− t `elem` ["h1","h2","h3","h4","h5","h6","dl","ol","ul","table","div","p"] &&
1042− t2 `elem` ["h1","h2","h3","h4","h5","h6","p" ] = True -- not "div"
1045+ t `elem` ["h1","h2","h3","h4","h5","h6","dl","ol","ul","table","div","main","p"] &&
1046+ t2 `elem` ["h1","h2","h3","h4","h5","h6","p" ] = True -- not "div" or "main"
10431047t1 `closes` t2 |
10441048 t1 `Set.member` blockTags &&
10451049 t2 `Set.notMember` blockTags &&