Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Book appearances: Difference between revisions

From Wings of Fire Wiki
first draft of module (I'll add more later)
 
No edit summary
Line 14: Line 14:
delim = delim or '\n'
delim = delim or '\n'
local res = '';
local res = '';
-- iterate over substrings
for abbr in mw.text.gsplit(str, ' ', true) do
for abbr in mw.text.gsplit(str, ' ', true) do
local full = abbrs[abbr]
local full = abbrs[abbr]
if full then
if full then
res = res .. full .. delim
res = res .. full .. delim -- concat to result string
else
else
return '{{error|Unrecognized abbreviation <code>' .. abbr .. '</code>}}'
return '{{error|Unrecognized abbreviation <code>' .. abbr .. '</code>}}'

Revision as of 19:32, 15 April 2025

Documentation for this module may be created at Module:Book appearances/doc

-- local string = require("Module:String")

local p = {}

local abbrs = {
	["TDP"] = "The Dragonet Prophecy",
	["TLH"] = "The Lost Heir",
	["THK"] = "The Hidden Kingdom",
	["TDS"] = "The Dark Secret",
	["TBN"] = "The Brightest Night",
}

function p.generate_appearances_list(str, delim)
	delim = delim or '\n'
	local res = '';
	-- iterate over substrings
	for abbr in mw.text.gsplit(str, ' ', true) do
		local full = abbrs[abbr]
		if full then
			res = res .. full .. delim -- concat to result string
		else
			return '{{error|Unrecognized abbreviation <code>' .. abbr .. '</code>}}'
		end
	end
	return res
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.