summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-06-26 23:10:11 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-06-28 04:00:16 -0400
commitdb187348cd8bb17ce66d2d4c1db6a5ff46a1ffbc (patch)
treee82bafdb1447729a963a69c8d04451c4accf9ba8 /src/Text/Pandoc
parent4248f25152d5715ad99f9d8dda8bf83f33f650ff (diff)
Docx rdr: Avoid mapping makeHeaderAnchors globally
It only applies to headers, so we can just apply it when we make a header.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 5773027f2..42352a845 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -152,6 +152,7 @@ divAttrToContainers (c:cs) _ | isJust (isHeaderClass c) =
let n = fromJust (isHeaderClass c)
in
[(Container $ \blks ->
+ makeHeaderAnchor $
Header n ("", delete ("Heading" ++ show n) cs, []) (blksToInlines blks))]
divAttrToContainers (c:cs) kvs | c `elem` divsToKeep =
(Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs)
@@ -304,8 +305,8 @@ isAnchorSpan _ = False
dummyAnchors :: [String]
dummyAnchors = ["_GoBack"]
-makeHeaderAnchors :: Block -> Block
-makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
+makeHeaderAnchor :: Block -> Block
+makeHeaderAnchor h@(Header n (_, classes, kvs) ils) =
case filter isAnchorSpan ils of
[] -> h
(x@(Span (ident, _, _) _) : xs) ->
@@ -313,7 +314,7 @@ makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
True -> h
False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
_ -> h
-makeHeaderAnchors blk = blk
+makeHeaderAnchor blk = blk
parPartsToInlines :: [ParPart] -> DocxContext [Inline]
parPartsToInlines parparts = do
@@ -424,7 +425,6 @@ bodyToBlocks :: Body -> DocxContext [Block]
bodyToBlocks (Body bps) = do
blks <- concatMapM bodyPartToBlocks bps
return $
- map (makeHeaderAnchors) $
blocksToDefinitions $
blocksToBullets $ blks