Docx Reader: Simplify makeHeaderAnchors
Using pattern guard, in preparation for doing some more complicated stuff with it (recording header anchors, so we can change them to auto ids.)
This commit is contained in:
parent
ab76bbebbe
commit
1de8d4d087
1 changed files with 5 additions and 8 deletions
|
@ -306,14 +306,11 @@ dummyAnchors :: [String]
|
|||
dummyAnchors = ["_GoBack"]
|
||||
|
||||
makeHeaderAnchor :: Block -> Block
|
||||
makeHeaderAnchor h@(Header n (_, classes, kvs) ils) =
|
||||
case filter isAnchorSpan ils of
|
||||
[] -> h
|
||||
(x@(Span (ident, _, _) _) : xs) ->
|
||||
case ident `elem` dummyAnchors of
|
||||
True -> h
|
||||
False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
|
||||
_ -> h
|
||||
makeHeaderAnchor (Header n (_, classes, kvs) ils)
|
||||
| (x : xs) <- filter isAnchorSpan ils
|
||||
, (Span (ident, _, _) _) <- x
|
||||
, notElem ident dummyAnchors =
|
||||
Header n (ident, classes, kvs) (ils \\ (x:xs))
|
||||
makeHeaderAnchor blk = blk
|
||||
|
||||
parPartsToInlines :: [ParPart] -> DocxContext [Inline]
|
||||
|
|
Loading…
Add table
Reference in a new issue