模組:R:it:Sapere

維基詞典,自由的多語言詞典

此模块實現了參考模板 {{R:it:Sapere}}


local export = {}

function export.create(frame) 
	 local params = {
		[1] = {default = mw.title.getCurrentTitle().text},
		[2] = {},
		["sense"] = {},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local u = mw.ustring.char
	-- https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts#Superscripts_and_subscripts_block
	local superscripts = {
		u(0xb9),
		u(0xb2),
		u(0xb3),
		u(0x2074),
		u(0x2075),
		u(0x2076),
		u(0x2077),
		u(0x2078),
		u(0x2079),
	}
	
	local term = mw.uri.encode(args[1]) 
	local sense = tonumber(args["sense"] or '')
	if sense and sense >= 1 and sense <= 9 then
		term = term .. superscripts[sense]
	end
	local title = (args[2] or args[1]):gsub('_', ' ')
    
    local link = "[https://www.sapere.it/enciclopedia/" .. term .. ".html " 
    	.. title
    	.. (sense and ('<sup>' .. sense .. '</sup>') or '')
    	.. "] " ..
    	"in ''sapere.it'' – De Agostini Editore" 

	return link
end

return export