git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2141 from DigitalPublishingToolkit/icml-images

Fix image URIs in ICML output

commitc3cb27f2f2b8f3671097f0344b9a1a0762cc86d0 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 26 May 2015, 17:14 (11 years ago) parent6397c108af168a
2 files changed+5−3
src/Text/Pandoc/Writers/ICML.hs+3−1 tests/writer.icml+2−2
src/Text/Pandoc/Writers/ICML.hs+3−1
@@ -25,6 +25,7 @@ import Data.List (isPrefixOf, isInfixOf, stripPrefix)
2525import Data.Text as Text (breakOnAll, pack)
2626import Data.Monoid (mappend)
2727import Control.Monad.State
28+import Network.URI (isURI)
2829import qualified Data.Set as Set
2930
3031type Style = [String]
@@ -499,6 +500,7 @@ imageICML _ style _ (linkURI, _) =
499500 hh = show $ imgHeight `div` 2
500501 qw = show $ imgWidth `div` 4
501502 qh = show $ imgHeight `div` 4
503+ uriPrefix = if isURI linkURI then "" else "file:"
502504 (stlStr, attrs) = styleToStrAttr style
503505 props = inTags True "Properties" [] $ inTags True "PathGeometry" []
504506 $ inTags True "GeometryPathType" [("PathOpen","false")]
@@ -518,7 +520,7 @@ imageICML _ style _ (linkURI, _) =
518520 $ vcat [
519521 inTags True "Properties" [] $ inTags True "Profile" [("type","string")] $ text "$ID/Embedded"
520522 $$ selfClosingTag "GraphicBounds" [("Left","0"), ("Top","0"), ("Right", hw), ("Bottom", hh)]
521− , selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", linkURI)]
523+ , selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", uriPrefix++linkURI)]
522524 ]
523525 doc = inTags True "CharacterStyleRange" attrs
524526 $ inTags True "Rectangle" [("Self","uec"), ("ItemTransform", "1 0 0 1 "++qw++" -"++qh)]
tests/writer.icml+2−2
@@ -2514,7 +2514,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{</Content>
25142514 <GraphicBounds Left="0" Top="0" Right="150" Bottom="100" />
25152515 </Profile>
25162516 </Properties>
2517− <Link Self="ueb" LinkResourceURI="lalune.jpg" />
2517+ <Link Self="ueb" LinkResourceURI="file:lalune.jpg" />
25182518 </Image>
25192519 </Rectangle>
25202520 </CharacterStyleRange><Br />
@@ -2544,7 +2544,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{</Content>
25442544 <GraphicBounds Left="0" Top="0" Right="150" Bottom="100" />
25452545 </Profile>
25462546 </Properties>
2547− <Link Self="ueb" LinkResourceURI="movie.jpg" />
2547+ <Link Self="ueb" LinkResourceURI="file:movie.jpg" />
25482548 </Image>
25492549 </Rectangle>
25502550 </CharacterStyleRange>