aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-06-27 11:45:06 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-06-28 04:00:16 -0400
commit1de8d4d08788ef24f69f9f90266604854996080e (patch)
treeff2e9283becd5e256ea2a4a5740c01be886e8b31 /src/Text/Pandoc/Readers
parentab76bbebbe7afd3acdf3218b88f02482c885cc87 (diff)
downloadpandoc-1de8d4d08788ef24f69f9f90266604854996080e.tar.gz
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.)
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 0c52b1acb..9aaf1d340 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -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]