git.iko.soy/typeable/pandoc
on master help sign in
Docx rdr: Avoid mapping makeHeaderAnchors globally
db18734Jesse Rosenthal
src/Text/Pandoc/Readers/Docx.hs+4−4
@@ -152,6 +152,7 @@ divAttrToContainers (c:cs) _ | isJust (isHeaderClass c) =
152 let n = fromJust (isHeaderClass c)
152 let n = fromJust (isHeaderClass c)
153 in
153 in
154 [(Container $ \blks ->
154 [(Container $ \blks ->
155+ makeHeaderAnchor $
155 Header n ("", delete ("Heading" ++ show n) cs, []) (blksToInlines blks))]
156 Header n ("", delete ("Heading" ++ show n) cs, []) (blksToInlines blks))]
156divAttrToContainers (c:cs) kvs | c `elem` divsToKeep =
157divAttrToContainers (c:cs) kvs | c `elem` divsToKeep =
157 (Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs)
158 (Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs)
@@ -304,8 +305,8 @@ isAnchorSpan _ = False
304dummyAnchors :: [String]
305dummyAnchors :: [String]
305dummyAnchors = ["_GoBack"]
306dummyAnchors = ["_GoBack"]
306
307
307−makeHeaderAnchors :: Block -> Block
308+makeHeaderAnchor :: Block -> Block
308−makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
309+makeHeaderAnchor h@(Header n (_, classes, kvs) ils) =
309 case filter isAnchorSpan ils of
310 case filter isAnchorSpan ils of
310 [] -> h
311 [] -> h
311 (x@(Span (ident, _, _) _) : xs) ->
312 (x@(Span (ident, _, _) _) : xs) ->
@@ -313,7 +314,7 @@ makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
313 True -> h
314 True -> h
314 False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
315 False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
315 _ -> h
316 _ -> h
316−makeHeaderAnchors blk = blk
317+makeHeaderAnchor blk = blk
317
318
318parPartsToInlines :: [ParPart] -> DocxContext [Inline]
319parPartsToInlines :: [ParPart] -> DocxContext [Inline]
319parPartsToInlines parparts = do
320parPartsToInlines parparts = do
@@ -424,7 +425,6 @@ bodyToBlocks :: Body -> DocxContext [Block]
424bodyToBlocks (Body bps) = do
425bodyToBlocks (Body bps) = do
425 blks <- concatMapM bodyPartToBlocks bps
426 blks <- concatMapM bodyPartToBlocks bps
426 return $
427 return $
427− map (makeHeaderAnchors) $
428 blocksToDefinitions $
428 blocksToDefinitions $
429 blocksToBullets $ blks
429 blocksToBullets $ blks
430
430