Module:String2: Difference between revisions

Content deleted Content added
revert encoding output of hyphen2dash
add optional spacing parameter to hyphen2dash for improved support in templates r/rp/ran. Default is a normal space after the separating comma.
Line 308:
 
]]
function p.hyphen_to_dash( str, spacing )
if (str == nil or str == '') then
return str;
Line 337:
end
 
local temp_str = table.concat (out, ', ' .. spacing); -- concatenate the output table into a comma separated string
temp_str, accept = temp_str:gsub ('^%(%((.+)%)%)$', '%1'); -- remove accept-this-as-written markup when it wraps all of concatenated out
if accept ~= 0 then
Line 349:
function p.hyphen2dash( frame )
local str = frame.args[1] or ''
local spacing = frame.args[2] or ' ' -- space is part of the standard separator for normal spacing (but in conjunction with templates r/rp/ran we may need a narrower spacing
return p.hyphen_to_dash(str)
return p.hyphen_to_dash(str, spacing)
end