diff options
author | John MacFarlane <jgm@berkeley.edu> | 2013-11-30 17:00:58 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-11-30 17:00:58 -0800 |
commit | 7aa4d519686af1416eaf3b380f8584ab89569c41 (patch) | |
tree | d3b8b5913d51e9dc6d9f540e3284960e4a3f7e70 /src/Text | |
parent | dde484f80985411d1e51038e9347b47ff90a1b7e (diff) | |
download | pandoc-7aa4d519686af1416eaf3b380f8584ab89569c41.tar.gz |
ODT writer: Add `draw:name` attribute to `draw:frame` elements.
This is reported to be necessary to avoid an error from recent
versions of Libre Office when files contain more than one image.
Closes #1069.
Thanks to wmanley for reporting and diagnosing the problem.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/OpenDocument.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 565f5f869..4ddfd7166 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -64,6 +64,7 @@ data WriterState = , stInDefinition :: Bool , stTight :: Bool , stFirstPara :: Bool + , stImageId :: Int } defaultWriterState :: WriterState @@ -78,6 +79,7 @@ defaultWriterState = , stInDefinition = False , stTight = False , stFirstPara = False + , stImageId = 1 } when :: Bool -> Doc -> Doc @@ -380,7 +382,7 @@ inlineToOpenDocument o ils then return $ preformatted s else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l - | Image _ (s,t) <- ils = return $ mkImg s t + | Image _ (s,t) <- ils = mkImg s t | Note l <- ils = mkNote l | otherwise = return empty where @@ -389,7 +391,11 @@ inlineToOpenDocument o ils , ("xlink:href" , s ) , ("office:name", t ) ] . inSpanTags "Definition" - mkImg s t = inTags False "draw:frame" (attrsFromTitle t) $ + mkImg s t = do + id' <- gets stImageId + modify (\st -> st{ stImageId = id' + 1 }) + return $ inTags False "draw:frame" + (("draw:name", "img" ++ show id'):attrsFromTitle t) $ selfClosingTag "draw:image" [ ("xlink:href" , s ) , ("xlink:type" , "simple") , ("xlink:show" , "embed" ) |