"मोड्युल:Delink" का संशोधनहरू बिचको अन्तर
Content deleted Content added
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 = {}
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.
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 mw.ustring.len(s)
-- Replace text using one iteration of gsub.
s = mw.ustring.gsub(s, pattern, delinkFunction, 1)
Line १४६ ⟶ १४२:
end
local function
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)
local args
if frame == mw.getCurrentFrame() then
-- 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
end
|