Diff: Module:Anchor
Comparing revision #1 (2020-09-24 22:32:51) with revision #2 (2023-02-04 10:26:39).
| Old | New |
|---|---|
-- This module implements {{anchor}}. |
-- This module implements {{anchor}}. |
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
local tableTools = require('Module:TableTools') |
local tableTools = require('Module:TableTools') |
local p = {} |
local p = {} |
function p.main(frame) |
function p.main(frame) |
-- Get the positional arguments from #invoke, remove any nil values, |
-- Get the positional arguments from #invoke, remove any nil values, |
-- and pass them to p._main. |
-- and pass them to p._main. |
local args = getArgs(frame) |
local args = getArgs(frame) |
local argArray = tableTools.compressSparseArray(args) |
local argArray = tableTools.compressSparseArray(args) |
return p._main(unpack(argArray)) |
return p._main(unpack(argArray)) |
end |
end |
function p._main(...) |
function p._main(...) |
-- Generate the list of anchors. |
-- Generate the list of anchors. |
local anchors = {...} |
local anchors = {...} |
local ret = {} |
local ret = {} |
for _, anchor in ipairs(anchors) do |
for _, anchor in ipairs(anchors) do |
ret[#ret + 1] = '<span class="anchor" id="' .. anchor .. '"></span>' |
ret[#ret + 1] = '<span class="anchor" id="' .. anchor .. '"></span>' |
end |
end |
return table.concat(ret) |
return table.concat(ret) |
end |
end |
return p |
return p |