Skip to content

Commit 92fa8e9

Browse files
authored
Merge pull request #203 from danilka4/main
Added case where a hyperlink is an image
2 parents 67fb3e4 + 7089280 commit 92fa8e9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lua/feed/pandoc/gfm.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ function Writer(doc, opts)
2424
Link = function(elem)
2525
ref_counter = ref_counter + 1
2626
refs[ref_counter] = elem.target
27+
28+
-- Checks if extension is an image and treats it as such if it is
29+
local extension = elem.target:match("^.+%.(.+)$")
30+
if extension == "jpg" or extension == "jpeg" or extension == "png" or extension == "webm" then
31+
return pandoc.RawInline("markdown", ("![Image %d](%s)"):format(ref_counter, elem.target)) -- added for image rendering
32+
end
33+
2734
local text = pandoc.utils.stringify(elem.content)
2835
return pandoc.RawInline("markdown", "[" .. text .. "][^" .. ref_counter .. "]")
2936
end,

0 commit comments

Comments
 (0)