Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Danski454/chance
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--implement some tasks in [[Template:2nd chance]] local p = {} local getArgs = require('Module:Arguments').getArgs local displayError = require('Module:Error').error function p.main( frame ) local args = getArgs(frame) local title = args[1] local page = mw.title.new( title, 0 ) if (not page) or page.namespace ~= 0 or page.isExternal then return displayError({'"' .. title .. '" is not a valid article title'}) elseif not page.exists then--expensive return displayError({'"' .. title .. '" does not exist'}) elseif page.isRedirect then return displayError({'"' .. title .. '" is a redirect to "' .. page.redirectTarget.prefixedText .. '", you may be looking for that page instead'}) end local content = page:getContent() --remove unwanted content --content = string.gsub(content, "\n%s%[%[File:..-%]%]\n", "\n")--files --content = string.gsub(content, "{{[iI]nfobox..-}}%s*\n%s*([^|%s])", "%1")--infoboxes content = string.gsub(content, "%b[]", function (match) if string.find(match, "[[File:", 1, true) == 1 or string.find(match, "[[Image:", 1, true) == 1 then return "" end return match end)--files content = string.gsub(content, "{{[^{}\n]+%-stub}}", "")--stub templates content = string.gsub(content, "%b{}", function (match) if string.find(match, "{{[iI]nfobox") == 1 or string.find(match, "{{[mM]ultiple image") == 1 then return "" end return match end)--infoboxes and multiple images content = string.gsub(content, "%[%[Category%:..-%]%]", "")--categories content = string.gsub(content, "<gallery.*<\\gallery>", "")--galleries content = string.gsub(content, "==%s*References%s*==.+", "")--references etc section down content = string.gsub(content, "==%s*Notes%s*==.+", "")--references etc section down content = string.gsub(content, "==%s*Endnotes%s*==.+", "")--references etc section down content = string.gsub(content, "==%s*Footnotes%s*==.+", "")--references etc section down content = string.gsub(content, "==%s*Works cited%s*==.+", "")--references etc section down content = string.gsub(content, "==%s*Further reading%s*==.+", "")--references etc section down content = string.gsub(content, "==%s*External links%s*==.+", "")--references etc section down content = string.gsub(content, "\n=([^\n]+)=\n", "\n==%1==\n")--reduce heading levels --add header content = "== [[" .. title .. "]] ==\n" .. content .. "\n{{tref}}" return content end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Sandbox/Danski454/chance/doc
(
edit
)
Module:Yesno
(
edit
)