diff --git a/expected-auto.native b/expected-auto.native index 604cb86..144d73f 100644 --- a/expected-auto.native +++ b/expected-auto.native @@ -128,12 +128,29 @@ ( "subdir/someimage.png" , "" ) ] ] +, Figure + ( "" , [] , [] ) + (Caption + Nothing [ Plain [ Str "Image" , Space , Str "title" ] ]) + [ Plain + [ Image + ( "" , [] , [] ) + [ Str "Image" , Space , Str "title" ] + ( "https://example.com/someimage.png" , "" ) + ] + ] , Para [ Link ( "" , [] , [] ) [ Str "Some" , Space , Str "link" ] ( "subdir/someimage.png" , "" ) ] +, Para + [ Link + ( "" , [] , [] ) + [ Str "Some" , Space , Str "link" ] + ( "https://example.com/someimage.png" , "" ) + ] , Header 2 ( "source-include" , [] , [] ) diff --git a/expected.native b/expected.native index 4977f8d..c0889e7 100644 --- a/expected.native +++ b/expected.native @@ -128,12 +128,29 @@ ( "subdir/someimage.png" , "" ) ] ] +, Figure + ( "" , [] , [] ) + (Caption + Nothing [ Plain [ Str "Image" , Space , Str "title" ] ]) + [ Plain + [ Image + ( "" , [] , [] ) + [ Str "Image" , Space , Str "title" ] + ( "https://example.com/someimage.png" , "" ) + ] + ] , Para [ Link ( "" , [] , [] ) [ Str "Some" , Space , Str "link" ] ( "subdir/someimage.png" , "" ) ] +, Para + [ Link + ( "" , [] , [] ) + [ Str "Some" , Space , Str "link" ] + ( "https://example.com/someimage.png" , "" ) + ] , Header 1 ( "source-include" , [] , [] ) diff --git a/include-files.lua b/include-files.lua index 69df689..9fc1a8e 100644 --- a/include-files.lua +++ b/include-files.lua @@ -36,6 +36,9 @@ local function update_contents(blocks, shift_by, include_path) end, -- If link paths are relative then prepend include file path Link = function (link) + if string.match(link.target, "^%a+://") then + return link + end if path.is_relative(link.target) then link.target = path.normalize(path.join({include_path, link.target})) end @@ -43,6 +46,9 @@ local function update_contents(blocks, shift_by, include_path) end, -- If image paths are relative then prepend include file path Image = function (image) + if string.match(image.src, "^%a+://") then + return image + end if path.is_relative(image.src) then image.src = path.normalize(path.join({include_path, image.src})) end diff --git a/subdir/file-g.md b/subdir/file-g.md index 818cf27..cd97dcd 100644 --- a/subdir/file-g.md +++ b/subdir/file-g.md @@ -4,8 +4,12 @@ Image relative path will be updated. ![Image title](someimage.png) +![Image title](https://example.com/someimage.png) + [Some link](someimage.png) +[Some link](https://example.com/someimage.png) + # Source include File inclusion codeblocks for use with include-code-files will be