Module:Dash: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
Try moving switch statements to module itself
ArrowHead294 (talk | contribs)
No edit summary
Line 6: Line 6:
if frame.args["spaces"] == "thin" then
if frame.args["spaces"] == "thin" then
sp = "\u{2009}"
sp = "\226\128\137"
elseif frame.args["spaces"] == "hair" then
elseif frame.args["spaces"] == "hair" then
sp = "\u{200A}"
sp = "\226\128\138"
else
else
sp = " "
sp = " "
Line 14: Line 14:
if frame.args["separator"] == "mdash" then
if frame.args["separator"] == "mdash" then
sp = "\u{2014}"
sp = "\226\130\148"
elseif frame.args["separator"] == "ndash" then
elseif frame.args["separator"] == "ndash" then
sp = "\u{2013}"
sp = "\226\130\147"
else
else
sp = "-"
sp = "-"

Revision as of 03:24, 12 May 2024

Module documentation[view] [edit] [history] [purge]
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 
Functions provided (1)
Line Function Params
3 dashes (invokable) (frame)
Lua modules required (0)
Variable Module Functions used

No function descriptions were provided. The Lua code may have further information.


local p = {}

function p.dashes(frame)
	local sp = ""
	local se = ""
	
	if frame.args["spaces"] == "thin" then
		sp = "\226\128\137"
	elseif frame.args["spaces"] == "hair" then
		sp = "\226\128\138"
	else
		sp = " "
	end
	
	if frame.args["separator"] == "mdash" then
		sp = "\226\130\148"
	elseif frame.args["separator"] == "ndash" then
		sp = "\226\130\147"
	else
		sp = "-"
	end
	
	return frame.args["input_str"]:gsub("%s+", sp .. se .. sp)
end

return p