コンテンツにスキップ

このWebサイトは、管理人が個人的に書き留めている備忘録です。それ以上でもそれ以下でもありません。
誤記・誤解・誤謬を含め、記述内容の確度を一切保証しません。責任を負いません。問い合わせ等を受け付けません。
This Mediawiki is a personal memorandum written by Administrator, nothing more, nothing less.
Administrator do NOT guarantee accuracy of content, including any errors, misunderstandings, fallacies, take NO responsibility, do NOT accept inquiries anything of the sort.

モジュール:Anchor

提供: Memorandum

このモジュールについての説明文ページを モジュール:Anchor/doc に作成できます

-- This module implements {{anchor}}.

local getArgs = require('Module:Arguments').getArgs
local tableTools = require('Module:TableTools')

local p = {}

function p.main(frame)
	-- Get the positional arguments from #invoke, remove any nil values,
	-- and pass them to p._main.
	local args = getArgs(frame)
	local argArray = tableTools.compressSparseArray(args)
	return p._main(unpack(argArray))
end

function p._main(...)
	-- Generate the list of anchors.
	local anchors = {...}
	local ret = {}
	for _, anchor in ipairs(anchors) do
		ret[#ret + 1] = '<span id="' .. anchor .. '"></span>'
	end
	return table.concat(ret)
end

return p