Docx reader: Single-item headers in ordered lists are headers.

When users number their headers, Word understands that as a single item
enumerated list. We make the assumption that such a list is, in fact, a header.
This commit is contained in:
Jesse Rosenthal 2014-09-04 16:35:57 -04:00
parent db90667a79
commit 7fe54505df

View file

@ -160,8 +160,14 @@ flatToBullets' num xs@(b : elems)
flatToBullets :: [Block] -> [Block] flatToBullets :: [Block] -> [Block]
flatToBullets elems = flatToBullets' (-1) elems flatToBullets elems = flatToBullets' (-1) elems
singleItemHeaderToHeader :: Block -> Block
singleItemHeaderToHeader (OrderedList _ [[h@(Header _ _ _)]]) = h
singleItemHeaderToHeader blk = blk
blocksToBullets :: [Block] -> [Block] blocksToBullets :: [Block] -> [Block]
blocksToBullets blks = blocksToBullets blks =
map singleItemHeaderToHeader $
bottomUp removeListDivs $ bottomUp removeListDivs $
flatToBullets $ (handleListParagraphs blks) flatToBullets $ (handleListParagraphs blks)
@ -221,7 +227,3 @@ removeListDivs = concatMap removeListDivs'
blocksToDefinitions :: [Block] -> [Block] blocksToDefinitions :: [Block] -> [Block]
blocksToDefinitions = blocksToDefinitions' [] [] blocksToDefinitions = blocksToDefinitions' [] []