Merge pull request #1746 from shelf/dw-ext-images

DokuWiki writer: fix external images
This commit is contained in:
Matthew Pickering 2014-12-08 23:55:36 +00:00
commit 48e2586ec8
5 changed files with 12 additions and 2 deletions

View file

@ -170,6 +170,8 @@ Extra-Source-Files:
tests/lhs-test.html+lhs
tests/lhs-test.fragment.html+lhs
tests/pipe-tables.txt
tests/dokuwiki_external_images.dokuwiki
tests/dokuwiki_external_images.native
tests/dokuwiki_multiblock_table.dokuwiki
tests/dokuwiki_multiblock_table.native
tests/fb2/*.markdown

View file

@ -134,7 +134,9 @@ blockToDokuWiki opts (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
let opt = if null txt
then ""
else "|" ++ if null tit then capt else tit ++ capt
return $ "{{:" ++ src ++ opt ++ "}}\n"
-- Relative links fail isURI and receive a colon
prefix = if isURI src then "" else ":"
return $ "{{" ++ prefix ++ src ++ opt ++ "}}\n"
blockToDokuWiki opts (Para inlines) = do
indent <- stIndent <$> ask
@ -478,7 +480,9 @@ inlineToDokuWiki opts (Image alt (source, tit)) = do
("", []) -> ""
("", _ ) -> "|" ++ alt'
(_ , _ ) -> "|" ++ tit
return $ "{{:" ++ source ++ txt ++ "}}"
-- Relative links fail isURI and receive a colon
prefix = if isURI source then "" else ":"
return $ "{{" ++ prefix ++ source ++ txt ++ "}}"
inlineToDokuWiki opts (Note contents) = do
contents' <- blockListToDokuWiki opts contents

View file

@ -130,6 +130,8 @@ tests = [ testGroup "markdown"
"dokuwiki_inline_formatting.native" "dokuwiki_inline_formatting.dokuwiki"
, test "multiblock table" ["-r", "native", "-w", "dokuwiki", "-s"]
"dokuwiki_multiblock_table.native" "dokuwiki_multiblock_table.dokuwiki"
, test "external images" ["-r", "native", "-w", "dokuwiki", "-s"]
"dokuwiki_external_images.native" "dokuwiki_external_images.dokuwiki"
]
, testGroup "opml"
[ test "basic" ["-r", "native", "-w", "opml", "--columns=78", "-s"]

View file

@ -0,0 +1 @@
{{https://cooluri.com/image.png|HTTPS image}} {{http://cooluri.com/image.png|HTTP image}} {{ftp://ftp.cooluri.com/image.png|FTP image}} {{file:///tmp/coolimage.png|Filesystem image}} {{:/image.jpg|Relative image 1}} {{:image.jpg|Relative image 2}}

View file

@ -0,0 +1 @@
[Para [Image [Str "HTTPS",Space,Str "image"] ("https://cooluri.com/image.png",""),Space,Image [Str "HTTP",Space,Str "image"] ("http://cooluri.com/image.png",""),Space,Image [Str "FTP",Space,Str "image"] ("ftp://ftp.cooluri.com/image.png",""),Space,Image [Str "Filesystem",Space,Str "image"] ("file:///tmp/coolimage.png",""),Space,Image [Str "Relative",Space,Str "image",Space,Str "1"] ("/image.jpg",""),Space,Image [Str "Relative",Space,Str "image",Space,Str "2"] ("image.jpg","")]]