diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-09-06 09:05:34 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-09-06 09:05:52 -0700 |
commit | 212406a61d027d85712705e626954e0486a2bc34 (patch) | |
tree | 69d02f88a373562133467621f21aee65ad3e1ac2 /src | |
parent | 6e2cfd6c97b1b8657f1f3e2b66090a2c3ba8d887 (diff) | |
download | pandoc-212406a61d027d85712705e626954e0486a2bc34.tar.gz |
hierarchicalize: ensure that sections get ids...
even if they're in divs. Improves #3057.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 4dc2484e7..a5acc6c15 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -523,19 +523,23 @@ hierarchicalizeWithIds (Header level attr@(_,classes,_) title':xs) = do sectionContents' <- hierarchicalizeWithIds sectionContents rest' <- hierarchicalizeWithIds rest return $ Sec level newnum attr title' sectionContents' : rest' -hierarchicalizeWithIds (Div attr@(_,classes',_) - (Header level (_,classes,_) title' : xs):ys) - | not ("columns" `elem` classes') - , not ("column" `elem` classes') = do +hierarchicalizeWithIds (Div (dident,dclasses,dkvs) + (Header level (hident,hclasses,hkvs) title' : xs):ys) + | not ("columns" `elem` dclasses) + , not ("column" `elem` dclasses) = do lastnum <- S.get let lastnum' = take level lastnum let newnum = case length lastnum' of - x | "unnumbered" `elem` classes -> [] + x | "unnumbered" `elem` hclasses -> [] | x >= level -> init lastnum' ++ [last lastnum' + 1] | otherwise -> lastnum ++ replicate (level - length lastnum - 1) 0 ++ [1] unless (null newnum) $ S.put newnum - sectionContents' <- hierarchicalizeWithIds xs + let attr = (hident, dclasses ++ hclasses, dkvs ++ hkvs) + sectionContents' <- hierarchicalizeWithIds $ + if null dident -- ensure we don't lose an id + then xs + else [Div (dident,[],[]) xs] rest' <- hierarchicalizeWithIds ys return $ Sec level newnum attr title' sectionContents' : rest' hierarchicalizeWithIds (x:rest) = do |