Difference between revisions of "Module:Sandbox/Erutuon/Glossing abbreviations"

From blackwiki
Jump to navigation Jump to search
blackwiki>Erutuon
(attempt to create a module for simply creating abbr tags for glossing abbreviations)
 
blackwiki>Erutuon
(allow parent arguments)
Line 11: Line 11:
  
 
function p.abbr(frame)
 
function p.abbr(frame)
local abbreviation = frame.args[1] or error("Provide an abbreviation in parameter 1")
+
local parent = frame:getParent().args[1] and frame:getParent().args
 +
local abbreviation = frame.args[1] or parent.args[1] error("Provide an abbreviation in parameter 1")
 
local expanded = data[abbreviation] or error("The abbreviation "..(abbreviation or "nil").." is not recognized")
 
local expanded = data[abbreviation] or error("The abbreviation "..(abbreviation or "nil").." is not recognized")
 
return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>'
 
return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>'

Revision as of 01:43, 15 October 2016

This was an early module designed to format and expand glossing abbreviations. It was used by an earlier version of Template:Gloss-abbr. It has been superseded by Template:gcl (which uses Module:Interlinear).


local p = {}

local data = {
	["1s"] = "first person singular",
	["2s"] = "second person singular",
	["3s"] = "third person plural",
	["1p"] = "first person plural",
	["2p"] = "second person plural",
	["3p"] = "third person plural",
}

function p.abbr(frame)
	local parent = frame:getParent().args[1] and frame:getParent().args
	local abbreviation = frame.args[1] or parent.args[1] error("Provide an abbreviation in parameter 1")
	local expanded = data[abbreviation] or error("The abbreviation "..(abbreviation or "nil").." is not recognized")
	return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>'
end

return p