Module:Dash

From Xenharmonic Wiki
Revision as of 17:40, 22 May 2024 by ArrowHead294 (talk | contribs)
Jump to navigation Jump to search
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, se
	
	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
	else
		sp = ""												-- No space
	end
	
	if frame.args["d"] == "long" then
		se = "—"										-- U+2014 EM DASH
	elseif frame.args["d"] == "med" or frame.args["d"] == "medium" then
		se = "–"										-- U+2013 EN DASH
	elseif frame.args["d"] == "larr" then
		se = "←"                                     -- U+2190 ← LEFTWARDS ARROW
	elseif frame.args["d"] == "rarr" then
		se = "→"                                     -- U+2192 → RIGHTWARDS ARROW
	else
		se = "-"											-- Hyphen-minus
	end
	
	local out_str = frame.args["input_str"]:gsub(",%s+", sp .. se .. sp)
	
	return "<span>" .. out_str .. "</span>"
end

return p