diff options
-rw-r--r-- | pandoc.cabal | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/DokuWiki.hs | 8 | ||||
-rw-r--r-- | tests/Tests/Old.hs | 2 | ||||
-rw-r--r-- | tests/dokuwiki_external_images.dokuwiki | 1 | ||||
-rw-r--r-- | tests/dokuwiki_external_images.native | 1 |
5 files changed, 12 insertions, 2 deletions
diff --git a/pandoc.cabal b/pandoc.cabal index 20e06121b..da800ed50 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -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 diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs index 74418aa7e..eed45a965 100644 --- a/src/Text/Pandoc/Writers/DokuWiki.hs +++ b/src/Text/Pandoc/Writers/DokuWiki.hs @@ -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 diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index 0f7b33dd1..5bdf325b1 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -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"] diff --git a/tests/dokuwiki_external_images.dokuwiki b/tests/dokuwiki_external_images.dokuwiki new file mode 100644 index 000000000..cc7eddcda --- /dev/null +++ b/tests/dokuwiki_external_images.dokuwiki @@ -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}} diff --git a/tests/dokuwiki_external_images.native b/tests/dokuwiki_external_images.native new file mode 100644 index 000000000..c2b8876d3 --- /dev/null +++ b/tests/dokuwiki_external_images.native @@ -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","")]] |