diff options
author | John MacFarlane <jgm@berkeley.edu> | 2012-10-02 19:20:51 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2012-10-02 19:20:51 -0700 |
commit | 02bb0f051aee08e2b8a3aa1d8fba2d9f7398279c (patch) | |
tree | c6444ce3168441b66d364331371078bdfd04fb0e | |
parent | f9d76bd666885c93f10959979770e195259996a5 (diff) | |
download | pandoc-02bb0f051aee08e2b8a3aa1d8fba2d9f7398279c.tar.gz |
Use integer ids for bookmarks.
Closes #626.
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index f8e3370e4..e44f77497 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -50,6 +50,7 @@ import Text.XML.Light import Text.TeXMath import Control.Monad.State import Text.Highlighting.Kate +import Data.Unique (hashUnique, newUnique) data WriterState = WriterState{ stTextProperties :: [Element] @@ -333,11 +334,12 @@ blockToOpenXML opts (Header lev lst) = do contents <- withParaProp (pStyle $ "Heading" ++ show lev) $ blockToOpenXML opts (Para lst) usedIdents <- gets stSectionIds - let ident = uniqueIdent lst usedIdents - modify $ \s -> s{ stSectionIds = ident : stSectionIds s } - let bookmarkStart = mknode "w:bookmarkStart" [("w:id",ident) - ,("w:name",ident)] () - let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id",ident)] () + let bookmarkName = uniqueIdent lst usedIdents + modify $ \s -> s{ stSectionIds = bookmarkName : stSectionIds s } + id' <- liftIO $ hashUnique `fmap` newUnique + let bookmarkStart = mknode "w:bookmarkStart" [("w:id",show id') + ,("w:name",bookmarkName)] () + let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id",show id')] () return $ [bookmarkStart] ++ contents ++ [bookmarkEnd] blockToOpenXML opts (Plain lst) = blockToOpenXML opts (Para lst) blockToOpenXML opts (Para x@[Image alt _]) = do @@ -574,7 +576,7 @@ inlineToOpenXML _ (Code attrs str) = , mknode "w:t" [("xml:space","preserve")] tok ] inlineToOpenXML opts (Note bs) = do notes <- gets stFootnotes - let notenum = length notes + 1 + notenum <- liftIO $ hashUnique `fmap` newUnique let notemarker = mknode "w:r" [] [ mknode "w:rPr" [] (rStyle "FootnoteReference") , mknode "w:footnoteRef" [] () ] |