git.iko.soy/typeable/pandoc
on master help sign in
Changed hierarchicalize so it treats references div as top-level header.

Fixes a bug with `--section-divs`, where the final references section added by pandoc-citeproc, enclosed in its own div, got put in the div for the section previous to it. This fixes #2294. Longer term, we might think about how hierarchicalize should interact with Div elements.

commit2df3dfe88391f9e5a0ec4e10aff0abbf0c88bb0a authorJohn MacFarlane <jgm@berkeley.edu> dateSun 12 Jul 2015, 13:57 (11 years ago) parent0bd5873
1 file changed+5
src/Text/Pandoc/Shared.hs+5
src/Text/Pandoc/Shared.hs+5
@@ -662,12 +662,17 @@ hierarchicalizeWithIds ((Header level attr@(_,classes,_) title'):xs) = do
662662 sectionContents' <- hierarchicalizeWithIds sectionContents
663663 rest' <- hierarchicalizeWithIds rest
664664 return $ Sec level newnum attr title' sectionContents' : rest'
665+hierarchicalizeWithIds ((Div ("",["references"],[])
666+ (Header level (ident,classes,kvs) title' : xs)):ys) =
667+ hierarchicalizeWithIds ((Header level (ident,("references":classes),kvs)
668+ title') : (xs ++ ys))
665669hierarchicalizeWithIds (x:rest) = do
666670 rest' <- hierarchicalizeWithIds rest
667671 return $ (Blk x) : rest'
668672
669673headerLtEq :: Int -> Block -> Bool
670674headerLtEq level (Header l _ _) = l <= level
675+headerLtEq level (Div ("",["references"],[]) (Header l _ _ : _)) = l <= level
671676headerLtEq _ _ = False
672677
673678-- | Generate a unique identifier from a list of inlines.