Module:Sandbox/Sameboat/m3

.mw-parser-output .documentation,.mw-parser-output .documentation-metadata{border:1px solid var(--border-color-base,#a2a9b1);background-color:#ecfcf4;color:inhe

Module:Sandbox/Sameboat/m3
local p = {}

local function pre_block(text)
	-- Pre tags returned by a module do not act like wikitext <pre>...</pre>.
	return '<pre>' ..
		mw.text.nowiki(text) ..
		(text:sub(-1) == '\n' and '' or '\n') ..
		'</pre>\n'
end

function p.trimmer(frame)
-- Trims first and last empty icon cell of each row.
	local org = mw.text.unstripNoWiki(frame.args[1]) or 'Paste Routemap RDT markups between the nowiki tags'
	local res = org
	local restable = {}
	for i, v in ipairs(mw.text.split(res, '\n')) do
		v = mw.text.split(v, '\\')
		for _ in ipairs(v) do
			if v[1] == '' and v[table.maxn(v)] == '' then
				table.remove(v, 1)
				table.remove(v, table.maxn(v))
			end
			restable.row = table.concat(v, '\\')
		end
		table.insert(restable, restable.row)
	end
	--return table.concat(restable, '\n')
	return "\n'''Trimmed''':\n" .. pre_block(table.concat(restable, '\n')) .. "'''''Before trimming''''':\n" .. pre_block(org)
	--return table.maxn(mw.text.split([[1\2\3\4\5]], '\\'))
	--return table.concat(mw.text.split(mw.text.trim(org), '\\'), '\\')
	--return table.concat(mw.text.split([[\\\STR\STR\\]], '\\'), '\\')
end

function p.trimmer2(frame)
-- Trims first and last empty icon cell of each row.
	local org = mw.text.unstripNoWiki(frame.args[1]) or 'Paste Routemap RDT markups between the nowiki tags'
	local res = org
	local restable = {}
	for i, v in ipairs(mw.text.split(res, '\n')) do
		v = mw.text.split(v, '! !')
		for i2, v2 in ipairs(v) do
			v2 = mw.text.split(v2, '~~')
			for i3, v3 in ipairs(v) do
				v3 = mw.text.split(v3, '\\')
				for _ in ipairs(v3) do
					if v3[1] == '' and v[table.maxn(v3)] == '' then
						table.remove(v3, 1)
						table.remove(v3, table.maxn(v3))
					end
					restable.icon = table.concat(v3, '\\')
				end
				restable.right = {}
				table.insert(restable.right, restable.icon)
				restable.right2 = table.concat(restable.right, '~~')
			end
			restable.left = {}
			table.insert(restable.left, restable.right2)
			restable.left2 = table.concat(restable.left, '! !')
		end
		restable.row = {}
		table.insert(restable.row, restable.left2)
	end
	return "\n'''Trimmed''':\n" .. pre_block(table.concat(restable.row, '\n')) .. "'''''Before trimming''''':\n" .. pre_block(org)
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.