aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Shared.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 7c3546f44..949f53a3a 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -523,10 +523,21 @@ hierarchicalizeWithIds (Header level attr@(_,classes,_) title':xs) = do
sectionContents' <- hierarchicalizeWithIds sectionContents
rest' <- hierarchicalizeWithIds rest
return $ Sec level newnum attr title' sectionContents' : rest'
-hierarchicalizeWithIds (Div ("refs",classes',kvs')
- (Header level (ident,classes,kvs) title' : xs):ys) =
- hierarchicalizeWithIds (Header level (ident,"references":classes,kvs)
- title' : Div ("refs",classes',kvs') xs : ys)
+hierarchicalizeWithIds (Div attr@(_,classes',_)
+ (Header level (_,classes,_) title' : xs):ys)
+ | not ("columns" `elem` classes')
+ , not ("column" `elem` classes') = do
+ lastnum <- S.get
+ let lastnum' = take level lastnum
+ let newnum = case length lastnum' of
+ x | "unnumbered" `elem` classes -> []
+ | 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
+ rest' <- hierarchicalizeWithIds ys
+ return $ Sec level newnum attr title' sectionContents' : rest'
hierarchicalizeWithIds (x:rest) = do
rest' <- hierarchicalizeWithIds rest
return $ Blk x : rest'