Modulo:Sandbox/Lucamauri/modulotest: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 5: | Riga 5: | ||
end | end | ||
return p | return p | ||
local p = {} | local p = {} | ||
local first = {} | local first = {} | ||
function p.toglitag(testo) | function p.toglitag(testo) | ||
first = string.gsub(testo.args[1], string.char(127) .. "<" .. testo.args[2] .. ">", "") | first = string.gsub(testo.args[1], string.char(127) .. "<" .. testo.args[2] .. ">", "") | ||
return (string.gsub(first, "</" .. testo.args[2] .. ">", "")) | return (string.gsub(first, "</" .. testo.args[2] .. ">", "")) | ||
return mw.text.killMarkers("<pre>Prova</pre>") | return mw.text.killMarkers("<pre>Prova</pre>") | ||
return mw.text.killMarkers(testo.args[1]) | |||
end | |||
return p | |||
]]-- | ]]-- | ||
return mw.text.killMarkers( | local p = {} | ||
function p.main(frame) | |||
local text = frame.args[1] | |||
return p._main(text) | |||
end | |||
function p._main(text) | |||
if not text then return end | |||
text = mw.text.killMarkers(text) | |||
:gsub('<span class="nowrap">(.+)</span>', '%1') --remove nowrap while keeping text inside | |||
:gsub('<br ?/?>', ', ') --replace br with commas | |||
:gsub('<.->.-<.->', '') --strip out tags | |||
:gsub('%[%[%s*[Ff]ile%s*:.-%]%]', '') --strip out files | |||
:gsub('%[%[%s*[Ii]mage%s*:.-%]%]', '') --strip out use of image: | |||
:gsub('%[%[%s*[Cc]ategory%s*:.-%]%]', '') --strip out categories | |||
:gsub('%[%[[^%]]-|', '') --strip out piped link text | |||
:gsub('[%[%]]', '') --then strip out remaining [ and ] | |||
:gsub("'''''", "") --strip out bold italic markup | |||
:gsub("'''?", "") --not stripping out '''' gives correct output for bolded text in quotes | |||
return text | |||
end | end | ||
return p | return p |
Versione delle 18:19, 12 set 2018
La documentazione per questo modulo può essere creata in Modulo:Sandbox/Lucamauri/modulotest/man
--[[
local p = {}
function p.hello(frame)
return 'Hello'
end
return p
local p = {}
local first = {}
function p.toglitag(testo)
first = string.gsub(testo.args[1], string.char(127) .. "<" .. testo.args[2] .. ">", "")
return (string.gsub(first, "</" .. testo.args[2] .. ">", ""))
return mw.text.killMarkers("<pre>Prova</pre>")
return mw.text.killMarkers(testo.args[1])
end
return p
]]--
local p = {}
function p.main(frame)
local text = frame.args[1]
return p._main(text)
end
function p._main(text)
if not text then return end
text = mw.text.killMarkers(text)
:gsub('<span class="nowrap">(.+)</span>', '%1') --remove nowrap while keeping text inside
:gsub('<br ?/?>', ', ') --replace br with commas
:gsub('<.->.-<.->', '') --strip out tags
:gsub('%[%[%s*[Ff]ile%s*:.-%]%]', '') --strip out files
:gsub('%[%[%s*[Ii]mage%s*:.-%]%]', '') --strip out use of image:
:gsub('%[%[%s*[Cc]ategory%s*:.-%]%]', '') --strip out categories
:gsub('%[%[[^%]]-|', '') --strip out piped link text
:gsub('[%[%]]', '') --then strip out remaining [ and ]
:gsub("'''''", "") --strip out bold italic markup
:gsub("'''?", "") --not stripping out '''' gives correct output for bolded text in quotes
return text
end
return p