Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80
Модуль:Якорь — Энциклопедия Акриции

Модуль:Якорь

Материал из Энциклопедия Акриции

Для документации этого модуля может быть создана страница Модуль:Якорь/doc

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local compressSparseArray = require('Module:TableTools').compressSparseArray
local p = {}

local function unpack(...)
	local frame = ...
	local args
	if type(frame.args) == 'table' then
		args = getArgs(frame)
	elseif type(frame) == 'table' then
		args = frame
	else
		args = {...}
	end
	return args
end

function p._main(anchor, text, visible)
	local result = mw.html.create('span')
		:attr('id', anchor)
		:wikitext(text)
	if visible then
		result:addClass('highlight-target')
	end
	return tostring(result)
end

function p.main(...)
	local args = unpack(...)
	local anchors = compressSparseArray(args)
	local text
	local visible = yesno(args.visible or args.v)
	if visible then
		text = args.text or args['текст'] or args[1]
	end

	local result = text
	for i, v in ipairs(anchors) do
		result = p._main(anchors[i], result, visible)
		--[[
			создание старого вида якорей для совместимости,
			см. Обсуждение шаблона:Якорь#Новые html5 ссылки и старые
		]]
		local encoded_anchor = mw.uri.encode(anchors[i], 'WIKI'):gsub('%%', '.')
		if anchors[i] ~= encoded_anchor then
			result = p._main(encoded_anchor, result, visible)
		end
	end

	return result
end

return p

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80