"मोड्युल:Delink" का संशोधनहरू बिचको अन्तर

नयाँ पृष्ठ: -- This module de-links most wikitext. p = {} local function delinkReversePipeTrick(s) if mw.ustring.match(s, "^%[%[|.*[|\n]") then -- Check for newlines or mu...
(don't use globals)
(नयाँ पृष्ठ: -- This module de-links most wikitext. p = {} local function delinkReversePipeTrick(s) if mw.ustring.match(s, "^%[%[|.*[|\n]") then -- Check for newlines or mu...)
-- This module de-links most wikitext.
 
local p = {}
require('Module:No globals')
 
local p = {}
 
local getArgs
 
local function delinkReversePipeTrick(s)
if s:mw.ustring.match(s, "^%[%[|.*[|\n]") then -- Check for newlines or multiple pipes.
return s
else
return s:mw.ustring.match(s, "%[%[|(.*)%]%]")
end
end
-- First, remove the text before the first colon, if any.
if s:mw.ustring.match(s, ":") then
s = s:mw.ustring.match(s, "%[%[.-:(.*)|%]%]")
-- If there are no colons, grab all of the text apart from the square brackets and the pipe.
else
s = s:mw.ustring.match(s, "%[%[(.*)|%]%]")
end
-- Next up, brackets and commas.
if s:mw.ustring.match(s, "%(.-%)$") then -- Brackets trump commas.
s = s:mw.ustring.match(s, "(.-) ?%(.-%)$")
elseif s:mw.ustring.match(s, ",") then -- If there are no brackets, display only the text before the first comma.
s = s:mw.ustring.match(s, "(.-),.*$")
end
return s
local result = s
-- Deal with the reverse pipe trick.
if result:mw.ustring.match(result, "%[%[|") then
return delinkReversePipeTrick(result)
end
-- title area of the link, i.e. the part before any pipes.
local titlearea
if result:mw.ustring.match(result, "|") then -- Find if we're dealing with a piped link.
titlearea = result:mw.ustring.match(result, "^%[%[(.-)|.*%]%]")
else
titlearea = result:mw.ustring.match(result, "^%[%[(.-)%]%]")
end
-- Check for bad characters.
-- Check for categories, interwikis, and files.
local colonprefix = result:mw.ustring.match(result, "%[%[(.-):.*%]%]") or "" -- Get the text before the first colon.
local ns = mw.site.namespaces[colonprefix] -- see if this is a known namespace
if mw.language.isKnownLanguageTag(colonprefix)
-- Remove the colon if the link is using the [[Help:Colon trick]].
if result:mw.ustring.match(result, "%[%[:") then
result = "[[" .. result:mw.ustring.match(result, "%[%[:(.*%]%])")
end
-- Find the display area of the wikilink
if result:mw.ustring.match(result, "|") then -- Find if we're dealing with a piped link.
result = result:mw.ustring.match(result, "^%[%[.-|(.+)%]%]")
-- Remove new lines from the display of multiline piped links,
-- where the pipe is before the first new line.
result = result:mw.ustring.gsub(result, "\n", "")
else
result = result:mw.ustring.match(result, "^%[%[(.-)%]%]")
end
 
-- If the text contains a line break it is not formatted as a URL, regardless of other content.
if s:mw.ustring.match(s, "\n") then
return s
end
return s
end
s = s:mw.ustring.match(s, "^%[" .. url_prefix .. "(.*)%]") -- Grab all of the text after the URL prefix and before the final square bracket.
s = s:mw.ustring.match(s, '^.-(["<> ].*)') or "" -- Grab all of the text after the first URL separator character ("<> ).
s = mw.ustring.match(s, "^%s*(%S.*)$") or "" -- If the separating character was a space, trim it off.
local s_decoded = mw.text.decode(s, true)
if mw.ustring.match(s_decoded, "%c") then
return s
-- than just use gsub, otherwise nested links aren't detected properly.
local result = ""
while mw.ustring.len(s) ~=> ''0 do
-- Replace text using one iteration of gsub.
s = mw.ustring.gsub(s, pattern, delinkFunction, 1)
end
 
local function p._delink(args)
local text = args[1] or ""
if args.refs == "yes" then
end
if not (args.comments == "no") then
text = text:mw.ustring.gsub(text, "<!%-%-.-%-%->", "") -- Remove html comments.
end
if not (args.wikilinks == "no") then
-- and new lines only containing spaces or tabs before a second new line.
text = mw.ustring.gsub(text, "([^\n \t][ \t]*)\n([ \t]*[^\n \t])", "%1 %2")
text = text:mw.ustring.gsub(text, "[ \t]+", " ") -- Remove extra tabs and spaces.
end
return text
 
function p.delink(frame)
local args
if not getArgs then
if frame == mw.getCurrentFrame() then
getArgs = require('Module:Arguments').getArgs
-- We're being called via #invoke. If the invoking template passed any args, use
-- them. Otherwise, use the args that were passed into the template.
args = frame:getParent().args
for k, v in pairs(frame.args) do
args = frame.args
break
end
else
-- We're being called from another module or from the debug console, so assume
-- the args are passed in directly.
args = frame
end
return p._delink(getArgs(frame, {wrappers = 'Template:Delink'})args)
end
 
२६,७४९

edits

"https://ne.wikipedia.org/wiki/विशेष:MobileDiff/412308" बाट अनुप्रेषित