More actions
No edit summary |
Darkstalker refers to the character page, so use Darkstalker (book) instead |
||
| Line 19: | Line 19: | ||
["TDG"] = "[[The Dangerous Gift]]", | ["TDG"] = "[[The Dangerous Gift]]", | ||
["TFOH"] = "[[The Flames of Hope]]", | ["TFOH"] = "[[The Flames of Hope]]", | ||
["L1"] = "[[Darkstalker]]", | ["L1"] = "[[Darkstalker (book)|Darkstalker]]", | ||
["L2"] = "[[Dragonslayer]]", | ["L2"] = "[[Dragonslayer]]", | ||
["DS"] = "DS is ambiguous and could refer to Darkstalker (use L1) or Dragonslayer (use L2).", | ["DS"] = "DS is ambiguous and could refer to Darkstalker (use L1) or Dragonslayer (use L2).", | ||
Latest revision as of 09:15, 9 July 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]]",
["MR"] = "[[Moon Rising]]",
["WT"] = "[[Winter Turning]]",
["EP"] = "[[Escaping Peril]]",
["TOP"] = "[[Talons of Power]]",
["DOD"] = "[[Darkness of Dragons]]",
["TLC"] = "[[The Lost Continent]]",
["THQ"] = "[[The Hive Queen]]",
["TPJ"] = "[[The Poison Jungle]]",
["TDG"] = "[[The Dangerous Gift]]",
["TFOH"] = "[[The Flames of Hope]]",
["L1"] = "[[Darkstalker (book)|Darkstalker]]",
["L2"] = "[[Dragonslayer]]",
["DS"] = "DS is ambiguous and could refer to Darkstalker (use L1) or Dragonslayer (use L2).",
["W:P"] = "[[Prisoners]]",
["W:A"] = "[[Assassin]]",
["W:D"] = "[[Deserter]]",
["W:R"] = "[[Runaway]]",
["AGTTDW"] = "[[A Guide to the Dragon World]]",
["TOCB"] = "The Official Coloring Book",
["FYDW"] = "[[Forge Your Dragon World]]",
["HTD"] = "How to Draw",
["SGAB"] = "Stained Glass Art Book"
}
-- str: String to parse
-- delim: String to use to join the book names (default '\n')
function p._appearancesList(str, fmt, delim)
if not str or str == "" then
return ""
end
fmt = fmt or '%s'
delim = delim or '\n'
local names = mw.text.split(str, ' ', true)
-- iterate over substrings
for i, v in ipairs(names) do
if str == "" then
-- do notning
else
local full = abbrs[v]
if full then
names[i] = string.format(fmt, full)
else
return '{{error|Unrecognized abbreviation <code>' .. v .. '</code>}}'
end
end
end
return table.concat(names, delim)
end
-- wrapper for _appearancesList, untested
function p.appearancesList(frame)
local args = frame.args
local str = args.str or args[1]
local fmt = args.fmt or args[2] or "''%s''"
local delim = args.delim or args[3] or '<br>'
return frame:preprocess(p._appearancesList(str, fmt, delim))
end
return p