Module:Sound

Revision as of 05:42, 17 October 2025 by Cronos (talk | contribs) (Created page with "require( 'strict' ) local p = {} local template = '<span class="sound">' .. '<span class="sound-title">%s</span>' .. '<span style="display:none">class=sound-audio</span>' .. '</span>' function p.main(f) local args = f:getParent().args local result = {} local out = template if args.nofallback and args.nofallback ~= '' then out = out:gsub('display:none', '') end table.insert(result, mw.ustring.format(out, mw.text.trim(args[1] or ''), mw.text.t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sound/doc

require( 'strict' )
local p = {}
local template =
	'<span class="sound">' ..
		'<span class="sound-title">%s</span>' ..
		'<span style="display:none">[[File:%s|class=sound-audio]]</span>' ..
	'</span>'

function p.main(f)
	local args = f:getParent().args
	local result = {}
	local out = template

	if args.nofallback and args.nofallback ~= '' then
		out = out:gsub('display:none', '')
	end

	table.insert(result, mw.ustring.format(out, mw.text.trim(args[1] or ''),  mw.text.trim(args[2] or '') ) )

	for i, arg in ipairs(args) do
		arg = mw.text.trim(arg or '')
		if i > 2 and arg ~= '' then
			table.insert(result, mw.ustring.format(template, '', arg) )
		end
	end
	
	return table.concat(result)
end

return p