Docx Reader: Remove DummyListItem type
Change 5527465c
introduced a `DummyListItem` type in Docx/Parse.hs. In
retrospect, this seems like it mixes parsing and iterpretation
excessively. What's *really* going on is that we have a list item
without and associate level or numeric info. We can decide what to do
what that in Docx.hs (treat it like a list paragraph), but the parser
shouldn't make that decision.
This commit makes what is going on a bit more explicit. `LevelInfo` is
now a Maybe value in the `ListItem` type. If it's a Nothing, we treat
it as a ListParagraph. If it's a Just, it's a normal list item.
This commit is contained in:
parent
a008e57ddf
commit
07b8a456b1
2 changed files with 7 additions and 12 deletions
|
@ -486,7 +486,7 @@ bodyPartToBlocks (Paragraph pPr parparts)
|
|||
return $ case isNull ils' of
|
||||
True -> mempty
|
||||
_ -> parStyleToTransform pPr $ para ils'
|
||||
bodyPartToBlocks (ListItem pPr numId lvl levelInfo parparts) = do
|
||||
bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do
|
||||
let
|
||||
kvs = case levelInfo of
|
||||
(_, fmt, txt, Just start) -> [ ("level", lvl)
|
||||
|
@ -503,7 +503,7 @@ bodyPartToBlocks (ListItem pPr numId lvl levelInfo parparts) = do
|
|||
]
|
||||
blks <- bodyPartToBlocks (Paragraph pPr parparts)
|
||||
return $ divWith ("", ["list-item"], kvs) blks
|
||||
bodyPartToBlocks (DummyListItem pPr _ parparts) =
|
||||
bodyPartToBlocks (ListItem pPr _ _ _ parparts) =
|
||||
let pPr' = pPr {pStyle = "ListParagraph": (pStyle pPr)}
|
||||
in
|
||||
bodyPartToBlocks $ Paragraph pPr' parparts
|
||||
|
|
|
@ -177,8 +177,7 @@ defaultParagraphStyle = ParagraphStyle { pStyle = []
|
|||
|
||||
|
||||
data BodyPart = Paragraph ParagraphStyle [ParPart]
|
||||
| ListItem ParagraphStyle String String Level [ParPart]
|
||||
| DummyListItem ParagraphStyle String [ParPart]
|
||||
| ListItem ParagraphStyle String String (Maybe Level) [ParPart]
|
||||
| Tbl String TblGrid TblLook [Row]
|
||||
| OMathPara [Exp]
|
||||
deriving Show
|
||||
|
@ -565,9 +564,8 @@ elemToBodyPart ns element
|
|||
let parstyle = elemToParagraphStyle ns element sty
|
||||
parparts <- mapD (elemToParPart ns) (elChildren element)
|
||||
num <- asks envNumbering
|
||||
case lookupLevel numId lvl num of
|
||||
Just levelInfo -> return $ ListItem parstyle numId lvl levelInfo parparts
|
||||
Nothing -> return $ DummyListItem parstyle lvl parparts
|
||||
let levelInfo = lookupLevel numId lvl num
|
||||
return $ ListItem parstyle numId lvl levelInfo parparts
|
||||
elemToBodyPart ns element
|
||||
| isElem ns "w" "p" element = do
|
||||
sty <- asks envParStyles
|
||||
|
@ -576,11 +574,8 @@ elemToBodyPart ns element
|
|||
case pNumInfo parstyle of
|
||||
Just (numId, lvl) -> do
|
||||
num <- asks envNumbering
|
||||
case lookupLevel numId lvl num of
|
||||
Just levelInfo ->
|
||||
return $ ListItem parstyle numId lvl levelInfo parparts
|
||||
Nothing ->
|
||||
return $ DummyListItem parstyle lvl parparts
|
||||
let levelInfo = lookupLevel numId lvl num
|
||||
return $ ListItem parstyle numId lvl levelInfo parparts
|
||||
Nothing -> return $ Paragraph parstyle parparts
|
||||
elemToBodyPart ns element
|
||||
| isElem ns "w" "tbl" element = do
|
||||
|
|
Loading…
Add table
Reference in a new issue