hierarchicalize: ensure that sections get ids...
even if they're in divs. Improves #3057.
This commit is contained in:
parent
6e2cfd6c97
commit
212406a61d
2 changed files with 15 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
</div>
|
||||
</div>
|
||||
^D
|
||||
<section>
|
||||
<section xml:id="one">
|
||||
<title>one</title>
|
||||
<section>
|
||||
<section xml:id="two">
|
||||
<title>two</title>
|
||||
<para>
|
||||
</para>
|
||||
|
@ -26,9 +26,9 @@
|
|||
</div>
|
||||
</div>
|
||||
^D
|
||||
<section>
|
||||
<section xml:id="one">
|
||||
<title>one</title>
|
||||
<section>
|
||||
<section xml:id="two">
|
||||
<title>two</title>
|
||||
<para>
|
||||
</para>
|
||||
|
@ -48,7 +48,7 @@
|
|||
<para>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<section xml:id="two">
|
||||
<title>two</title>
|
||||
<para>
|
||||
</para>
|
||||
|
|
Loading…
Add table
Reference in a new issue