Revert changes to hierarchicalizeWithIds.

Revert "hierarchicalize: ensure that sections get ids..."
This reverts commit 212406a61d.

Revert "Improve detection of headings in Divs by hierarchicalize."
This reverts commit 6e2cfd6c97.

Revert "Shared.hierarchicalize: improve handling of div and section structure."
This reverts commit 345b33762e.
This commit is contained in:
John MacFarlane
2019-09-08 21:56:42 -07:00
parent 95a19fcff0
commit 1ccff3339d
2 changed files with 5 additions and 77 deletions
+5 -21
View File
@@ -523,33 +523,17 @@ hierarchicalizeWithIds (Header level attr@(_,classes,_) title':xs) = do
sectionContents' <- hierarchicalizeWithIds sectionContents
rest' <- hierarchicalizeWithIds rest
return $ Sec level newnum attr title' sectionContents' : rest'
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` hclasses -> []
| x >= level -> init lastnum' ++ [last lastnum' + 1]
| otherwise -> lastnum ++
replicate (level - length lastnum - 1) 0 ++ [1]
unless (null newnum) $ S.put newnum
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 (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 (x:rest) = do
rest' <- hierarchicalizeWithIds rest
return $ Blk x : rest'
headerLtEq :: Int -> Block -> Bool
headerLtEq level (Header l _ _) = l <= level
headerLtEq level (Div ("",classes,[]) (Header l _ _ : _)) =
l <= level && "column" `notElem` classes && "columns" `notElem` classes
headerLtEq level (Div ("",["references"],[]) (Header l _ _ : _)) = l <= level
headerLtEq _ _ = False
-- | Generate a unique identifier from a list of inlines.
-56
View File
@@ -1,56 +0,0 @@
```
% pandoc -f markdown -t docbook
<div>
# one
<div>
## two
</div>
</div>
^D
<section xml:id="one">
<title>one</title>
<section xml:id="two">
<title>two</title>
<para>
</para>
</section>
</section>
```
```
% pandoc -f markdown -t docbook
<div>
# one
<div>
# two
</div>
</div>
^D
<section xml:id="one">
<title>one</title>
<section xml:id="two">
<title>two</title>
<para>
</para>
</section>
</section>
```
```
% pandoc -f markdown -t docbook
# one
<div>
# two
</div>
^D
<section xml:id="one">
<title>one</title>
<para>
</para>
</section>
<section xml:id="two">
<title>two</title>
<para>
</para>
</section>
```