Module:Infobox Tools: Difference between revisions

Adding the function linkify_equip_list to make links out of the comma separated list
(Removing the links from guess_length as that has been moved to the template.)
Tag: Manual revert
(Adding the function linkify_equip_list to make links out of the comma separated list)
Line 169:
output_str = string.gsub(output_str, "Poker chips", "[[Poker chips]]");
output_str = string.gsub(output_str, "poker chips", "[[poker chips]]");
return output_str;
end
 
--Create wiki links from the comma separated list of extra equipment
function str.linkify_equip_list(frame)
local source_str = tostring(frame.args[1]);
local output_str = '';
local temp_str;
--escape pattern characters and remove problem ones
temp_str = str._scrubtext(source_str);
temp_str = string.gsub(temp_str, "%%", "");
 
--Add a comma to the end of the list so the loop can find every item
temp_str = temp_str .. ',';
--Loop through the list and append link brackets and the value to the output
for w in str:gmatch("(.-),") do output_str = output_str .. '[[' .. w .. ']]' end
return output_str;