Module:anchors

Hello, you have come here looking for the meaning of the word Module:anchors. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:anchors, but we will also tell you about its etymology, its characteristics and you will know how to say Module:anchors in singular and plural. Everything you need to know about the word Module:anchors you have here. The definition of the word Module:anchors will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:anchors, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local anchor_encode = mw.uri.anchorEncode
local encode_entities = require("Module:string utilities").encode_entities
local concat = table.concat
local insert = table.insert
local language_anchor -- Defined below.

function export.language_anchor(lang, id)
	return anchor_encode(lang:getFullName() .. ": " .. id)
end
language_anchor = export.language_anchor

function export.make_anchors(ids)
	local anchors = {}
	for i = 1, #ids do
		local id = ids
		insert(anchors, "<span class=\"template-anchor\" id=\"" .. anchor_encode(id) .. "\" data-id=\"" .. encode_entities(id) .. "\"></span>")
	end
	return concat(anchors)
end

function export.senseid(lang, id, tag_name)
	-- The following tag is opened but never closed, where is it supposed to be closed?
	--         with <li> it doesn't matter, as it is closed automatically.
	--         with <p> it is a problem
	
	return "<" .. tag_name .. " class=\"senseid\" id=\"" .. language_anchor(lang, id) .. "\" lang=\"" .. lang:getCode() .. "\" data-id=\"" .. encode_entities(id) .. "\">"
end

function export.etymid(lang, id)
	return "<span class=\"etymid\" id=\"" .. language_anchor(lang, id) .. "\" lang=\"" .. lang:getCode() .. "\" data-id=\"" .. encode_entities(id) .. "\"></span>"
end


return export