git.iko.soy/typeable/pandoc
on master help sign in
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.)

commit1de8d4d08788ef24f69f9f90266604854996080e authorJesse Rosenthal <jrosenthal@jhu.edu> dateFri 27 Jun 2014, 11:45 (12 years ago) parentab76bbe
1 file changed+5−8
src/Text/Pandoc/Readers/Docx.hs+5−8
src/Text/Pandoc/Readers/Docx.hs+5−8
@@ -306,14 +306,11 @@ dummyAnchors :: [String]
306306dummyAnchors = ["_GoBack"]
307307
308308makeHeaderAnchor :: Block -> Block
309−makeHeaderAnchor h@(Header n (_, classes, kvs) ils) =
310− case filter isAnchorSpan ils of
311− [] -> h
312− (x@(Span (ident, _, _) _) : xs) ->
313− case ident `elem` dummyAnchors of
314− True -> h
315− False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
316− _ -> h
309+makeHeaderAnchor (Header n (_, classes, kvs) ils)
310+ | (x : xs) <- filter isAnchorSpan ils
311+ , (Span (ident, _, _) _) <- x
312+ , notElem ident dummyAnchors =
313+ Header n (ident, classes, kvs) (ils \\ (x:xs))
317314makeHeaderAnchor blk = blk
318315
319316parPartsToInlines :: [ParPart] -> DocxContext [Inline]