"मोड्युल:Delink" का संशोधनहरू बिचको अन्तर
Content deleted Content added
नयाँ पृष्ठ: -- This module de-links most wikitext. p = {} local function delinkReversePipeTrick(s) if mw.ustring.match(s, "^%[%[|.*[|\n]") then -- Check for newlines or mu... |
सा Protected "Module:Delink": Highly visible template: 55,000+ mainspace transclusions ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) |
||
पङ्क्ति १:
-- This module de-links most wikitext.
require('Module:No globals')
p = {}▼
▲local p = {}
local getArgs
local function delinkReversePipeTrick(s)
if
return s
else
return
end
end
Line १६ ⟶ २०:
-- First, remove the text before the first colon, if any.
if
s =
-- If there are no colons, grab all of the text apart from the square brackets and the pipe.
else
s =
end
-- Next up, brackets and commas.
if
s =
elseif
s =
end
return s
Line ३५ ⟶ ३९:
local result = s
-- Deal with the reverse pipe trick.
if
return delinkReversePipeTrick(result)
end
Line ४५ ⟶ ४९:
-- title area of the link, i.e. the part before any pipes.
local titlearea
if
titlearea =
else
titlearea =
end
-- Check for bad characters.
Line ५६ ⟶ ६०:
-- Check for categories, interwikis, and files.
local colonprefix =
local ns = mw.site.namespaces[colonprefix] -- see if this is a known namespace
if mw.language.isKnownLanguageTag(colonprefix)
Line ६४ ⟶ ६८:
-- Remove the colon if the link is using the [[Help:Colon trick]].
if
result = "[[" ..
end
Line ७४ ⟶ ७८:
-- Find the display area of the wikilink
if
result =
-- Remove new lines from the display of multiline piped links,
-- where the pipe is before the first new line.
result =
else
result =
end
Line ९१ ⟶ ९५:
-- If the text contains a line break it is not formatted as a URL, regardless of other content.
if
return s
end
Line १०९ ⟶ ११३:
return s
end
s =
s =
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
Line १३२ ⟶ १३६:
-- than just use gsub, otherwise nested links aren't detected properly.
local result = ""
while
-- Replace text using one iteration of gsub.
s = mw.ustring.gsub(s, pattern, delinkFunction, 1)
Line १४२ ⟶ १४६:
end
local text = args[1] or ""
if args.refs == "yes" then
Line १५० ⟶ १५४:
end
if not (args.comments == "no") then
text =
end
if not (args.wikilinks == "no") then
Line १६२ ⟶ १६६:
-- 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 =
end
return text
Line १६८ ⟶ १७२:
function p.delink(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return p._delink(
end
|