diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 1badeeb589e3..2c748dc5f462 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -547,9 +547,14 @@ makeSectionsWithOffsets numoffsets numbering mbBaseLevel bs = ("number", T.intercalate "." (map tshow newnum)) : kvs _ -> kvs let divattr = (ident, "section":classes, kvs') - let attr = ("",classes,kvs') + let isHeadingAttr ("epub:type",_) = False + isHeadingAttr ("role",v) = + v `elem` ["tab", "presentation", "none", "treeitem", + "menuitem", "button", "heading"] + isHeadingAttr _ = True + let hattr = ("",classes, filter isHeadingAttr kvs') return $ - Div divattr (Header level' attr title' : sectionContents') : rest' + Div divattr (Header level' hattr title' : sectionContents') : rest' go (Div divattr@(dident,dclasses,_) (Header level hattr title':ys) : xs) | all (\case Header level' _ _ -> level' > level diff --git a/src/Text/Pandoc/Writers/DocBook.hs b/src/Text/Pandoc/Writers/DocBook.hs index bae20c6dcfe2..a2daf897e51b 100644 --- a/src/Text/Pandoc/Writers/DocBook.hs +++ b/src/Text/Pandoc/Writers/DocBook.hs @@ -174,7 +174,8 @@ imageToDocBook _ attr src = selfClosingTag "imagedata" $ blockToDocBook :: PandocMonad m => WriterOptions -> Block -> DB m (Doc Text) -- Add ids to paragraphs in divs with ids - this is needed for -- pandoc-citeproc to get link anchors in bibliographies: -blockToDocBook opts (Div (id',"section":_,_) (Header lvl (_,classes,attrs) ils : xs)) = do +blockToDocBook opts (Div (id',"section":_classes,divattrs) + (Header lvl (_,hclasses,_) ils : xs)) = do version <- ask -- DocBook doesn't allow sections with no content, so insert some if needed let bs = if null xs @@ -198,7 +199,7 @@ blockToDocBook opts (Div (id',"section":_,_) (Header lvl (_,classes,attrs) ils : -- Populate miscAttr with Header.Attr.attributes, filtering out non-valid DocBook section attributes, id, and xml:id -- Also enrich the role attribute with certain class tokens - miscAttr = enrichRole (filter (isSectionAttr version) attrs) classes + miscAttr = enrichRole (filter (isSectionAttr version) divattrs) hclasses attribs = nsAttr <> idAttr <> miscAttr title' <- inlinesToDocBook opts ils contents <- blocksToDocBook opts bs