Skip to content

Commit bd417e0

Browse files
committed
Thêm Webarchive và Svg
1 parent 90d9d17 commit bd417e0

4 files changed

Lines changed: 1760 additions & 0 deletions

File tree

‎Other/Svg.lua‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require[[strict]]
2+
3+
4+
local iface = {}
5+
6+
7+
iface.create = function (frame)
8+
local opts = frame.args
9+
local src
10+
local target
11+
if opts.content ~= nil then src = opts.content:match'^%s*(.*%S)' end
12+
if opts.link ~= nil then target = opts.link:match'^%s*(.*%S)' end
13+
if src == nil then return '' end
14+
local img = mw.svg.new()
15+
for key, val in pairs(opts) do
16+
if key ~= 'content' and key ~= 'link' and type(key) == 'string' then
17+
if key:sub(1, 1) == '#' then
18+
img:setAttribute(key:sub(2), val)
19+
elseif val ~= '' then img:setImgAttribute(key, val) end
20+
end
21+
end
22+
if target == nil then return img:setContent(src):toImage() end
23+
return '[[:' .. target .. '|' .. img:setContent(src):toImage() .. ']]'
24+
end
25+
26+
27+
iface.create_from_caller = function (frame)
28+
return iface.create(frame:getParent())
29+
end
30+
31+
32+
return iface

0 commit comments

Comments
 (0)