diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-06-28 03:04:34 -0400 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-06-28 04:00:16 -0400 |
commit | b89a3ba2b1069205a308ad0f444457d595e5a77f (patch) | |
tree | d7fdbc89a4acbfdd9e9d89c1f7c9eb01698077c9 /src/Text/Pandoc | |
parent | 5969baf5b97c0926384b1619be3c4be6d92b277b (diff) | |
download | pandoc-b89a3ba2b1069205a308ad0f444457d595e5a77f.tar.gz |
make makeHeaderAnchors make an auto id
Record relationship between original id and auto id, so we can fix links
after.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index bbe770f6e..a3053b72a 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -104,7 +104,7 @@ readDocx opts bytes = Nothing -> error $ "couldn't parse docx file" -data DState = DState { docxHdrLinks :: M.Map String String } +data DState = DState { docxHeaderAnchors :: M.Map String String } data DEnv = DEnv { docxOptions :: ReaderOptions , docxDocument :: Docx} @@ -310,7 +310,11 @@ makeHeaderAnchor (Header n (_, classes, kvs) ils) | (x : xs) <- filter isAnchorSpan ils , (Span (ident, _, _) _) <- x , notElem ident dummyAnchors = - return $ Header n (ident, classes, kvs) (ils \\ (x:xs)) + do + hdrIDMap <- gets docxHeaderAnchors + let newIdent = uniqueIdent ils (M.elems hdrIDMap) + put DState{docxHeaderAnchors = M.insert ident newIdent hdrIDMap} + return $ Header n (newIdent, classes, kvs) (ils \\ (x:xs)) makeHeaderAnchor blk = return blk @@ -432,7 +436,7 @@ bodyToBlocks (Body bps) = do docxToBlocks :: ReaderOptions -> Docx -> [Block] docxToBlocks opts d@(Docx (Document _ body) _ _ _ _) = - let dState = DState { docxHdrLinks = M.empty } + let dState = DState { docxHeaderAnchors = M.empty } dEnv = DEnv { docxOptions = opts , docxDocument = d} in |