Module:Dash: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) No edit summary |
ArrowHead294 (talk | contribs) No edit summary |
||
| Line 2: | Line 2: | ||
function p.dashes(frame) | function p.dashes(frame) | ||
local sp, | local sp, se1, se2 | ||
if frame.args["s"] == "thin" then | if frame.args["s"] == "thin" then | ||
| Line 19: | Line 19: | ||
if frame.args["d"] == "long" then | if frame.args["d"] == "long" then | ||
se1 = "—" -- U+2014 EM DASH | |||
elseif frame.args["d"] == "med" or frame.args["d"] == "medium" then | elseif frame.args["d"] == "med" or frame.args["d"] == "medium" then | ||
se1 = "–" -- U+2013 EN DASH | |||
elseif frame.args["d"] == "larr" then | elseif frame.args["d"] == "larr" then | ||
se1 = "←" -- U+2190 ← LEFTWARDS ARROW | |||
elseif frame.args["d"] == "rarr" then | elseif frame.args["d"] == "rarr" then | ||
se1 = "→" -- U+2192 → RIGHTWARDS ARROW | |||
else | else | ||
se1 = "-" -- Hyphen-minus | |||
end | end | ||
local out_str = frame.args["input_str"]:gsub(",%s+", sp .. | if frame.args["d2"] == "long" then | ||
se2 = "—" -- U+2014 EM DASH | |||
elseif frame.args["d2"] == "med" or frame.args["d2"] == "medium" then | |||
se2 = "–" -- U+2013 EN DASH | |||
elseif frame.args["d2"] == "larr" then | |||
se2 = "←" -- U+2190 ← LEFTWARDS ARROW | |||
elseif frame.args["d2"] == "rarr" then | |||
se2 = "→" -- U+2192 → RIGHTWARDS ARROW | |||
else | |||
se2 = "-" -- Hyphen-minus | |||
end | |||
local out_str = frame.args["input_str"]:gsub(",,%s+", sp .. se2 .. sp):gsub(",%s+", sp .. se1 .. sp) | |||
return "<span>" .. out_str .. "</span>" | return "<span>" .. out_str .. "</span>" | ||
Revision as of 12:38, 23 May 2024
- This module should not be invoked directly; use its corresponding template instead: Template:Dash.
Replaces comma and space in list with dashes and spaces.
| Introspection summary for Module:Dash | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
No function descriptions were provided. The Lua code may have further information.
local p = {};
function p.dashes(frame)
local sp, se1, se2
if frame.args["s"] == "thin" then
sp = " " -- U+2009 THIN SPACE
elseif frame.args["s"] == "hair" then
sp = " " -- U+200A HAIR SPACE
elseif frame.args["s"] == "space" then
sp = " " -- Regular space
elseif frame.args["s"] == "nbsp" then
sp = " " -- U+00A0 NO-BREAK SPACE
elseif frame.args["s"] == "nnbsp" then
sp = " " -- U+202F NARROW NO-BREAK SPACE
else
sp = "" -- No space
end
if frame.args["d"] == "long" then
se1 = "—" -- U+2014 EM DASH
elseif frame.args["d"] == "med" or frame.args["d"] == "medium" then
se1 = "–" -- U+2013 EN DASH
elseif frame.args["d"] == "larr" then
se1 = "←" -- U+2190 ← LEFTWARDS ARROW
elseif frame.args["d"] == "rarr" then
se1 = "→" -- U+2192 → RIGHTWARDS ARROW
else
se1 = "-" -- Hyphen-minus
end
if frame.args["d2"] == "long" then
se2 = "—" -- U+2014 EM DASH
elseif frame.args["d2"] == "med" or frame.args["d2"] == "medium" then
se2 = "–" -- U+2013 EN DASH
elseif frame.args["d2"] == "larr" then
se2 = "←" -- U+2190 ← LEFTWARDS ARROW
elseif frame.args["d2"] == "rarr" then
se2 = "→" -- U+2192 → RIGHTWARDS ARROW
else
se2 = "-" -- Hyphen-minus
end
local out_str = frame.args["input_str"]:gsub(",,%s+", sp .. se2 .. sp):gsub(",%s+", sp .. se1 .. sp)
return "<span>" .. out_str .. "</span>"
end
return p