git.iko.soy/typeable/pandoc
on master help sign in
Docx rdr: Avoid mapping makeHeaderAnchors globally

It only applies to headers, so we can just apply it when we make a header.

commitdb187348cd8bb17ce66d2d4c1db6a5ff46a1ffbc authorJesse Rosenthal <jrosenthal@jhu.edu> dateThu 26 Jun 2014, 23:10 (12 years ago) parent4248f25
1 file changed+4−4
src/Text/Pandoc/Readers/Docx.hs+4−4
src/Text/Pandoc/Readers/Docx.hs+4−4
@@ -152,6 +152,7 @@ divAttrToContainers (c:cs) _ | isJust (isHeaderClass c) =
152152 let n = fromJust (isHeaderClass c)
153153 in
154154 [(Container $ \blks ->
155+ makeHeaderAnchor $
155156 Header n ("", delete ("Heading" ++ show n) cs, []) (blksToInlines blks))]
156157divAttrToContainers (c:cs) kvs | c `elem` divsToKeep =
157158 (Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs)
@@ -304,8 +305,8 @@ isAnchorSpan _ = False
304305dummyAnchors :: [String]
305306dummyAnchors = ["_GoBack"]
306307
307−makeHeaderAnchors :: Block -> Block
308−makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
308+makeHeaderAnchor :: Block -> Block
309+makeHeaderAnchor h@(Header n (_, classes, kvs) ils) =
309310 case filter isAnchorSpan ils of
310311 [] -> h
311312 (x@(Span (ident, _, _) _) : xs) ->
@@ -313,7 +314,7 @@ makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
313314 True -> h
314315 False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
315316 _ -> h
316−makeHeaderAnchors blk = blk
317+makeHeaderAnchor blk = blk
317318
318319parPartsToInlines :: [ParPart] -> DocxContext [Inline]
319320parPartsToInlines parparts = do
@@ -424,7 +425,6 @@ bodyToBlocks :: Body -> DocxContext [Block]
424425bodyToBlocks (Body bps) = do
425426 blks <- concatMapM bodyPartToBlocks bps
426427 return $
427− map (makeHeaderAnchors) $
428428 blocksToDefinitions $
429429 blocksToBullets $ blks
430430