Skip to content

Commit 40344a3

Browse files
committed
Update pandoc_preserve_img.lua
1 parent 38a4df4 commit 40344a3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

.github/scripts/pandoc_preserve_img.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
-- 将 Pandoc AST 中的图片节点转换为原始 HTML <img>,保留宽高等属性
22

33
function Image(el)
4-
-- el.src, el.title, el.caption, el.attr
4+
-- el.src, el.title, el.caption, el.attributes
55
local src = el.src or (el.target and el.target[1]) or ""
66
local alt = pandoc.utils.stringify(el.caption or {})
77

88
local attrs = {}
9-
if el.attr and el.attr.attributes then
10-
for k, v in pairs(el.attr.attributes) do
9+
10+
-- 直接从 attributes 中取出 width/height 等所有原始属性
11+
if el.attributes then
12+
for k, v in pairs(el.attributes) do
1113
table.insert(attrs, string.format('%s="%s"', k, v))
1214
end
1315
end

0 commit comments

Comments
 (0)