Module:Dash: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {};
local p = {}


function p.dashes(frame)
-- Main function that does the substitution
function p._dash(in_str, s, d, d2)
local sp, se1, se2
local sp, se1, se2
local s = frame.args["s"]
local d = frame.args["d"]
local d2 = frame.args["d2"]
if s == "thin" then
if s == "thin" then
Line 47: Line 45:
end
end
local out_str = frame.args["input_str"]
local result = ((se2 == nil or se2 == "")
and in_str:gsub("[,|%s]*,%s+", sp .. se1 .. sp)
or in_str:gsub(",%s*,%s+", sp .. se2 .. sp):gsub(",%s+", sp .. se1 .. sp))
if se2 == "" then
return result
out_str = out_str:gsub("[,|%s]*,%s+", sp .. se1 .. sp)
end
else
 
out_str = out_str:gsub(",%s*,%s+", sp .. se2 .. sp):gsub(",%s+", sp .. se1 .. sp)
-- Wrapper function for Template:Dash
function p.dashes(frame)
local s = frame.args["s"]
local d = frame.args["d"]
local d2 = frame.args["d2"]
local in_str = frame.args["input_str"]
local debugg = frame.args["debug"]
local result = p._dash(in_str, s, d, d2)
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
end
out_str = "<span>" .. out_str .. "</span>"
return frame:preprocess(result)
return out_str
end
end


return p
return p