<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://159.13.49.45/index.php?action=history&amp;feed=atom&amp;title=Module%3ADelink</id>
	<title>Module:Delink - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://159.13.49.45/index.php?action=history&amp;feed=atom&amp;title=Module%3ADelink"/>
	<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Delink&amp;action=history"/>
	<updated>2026-04-03T23:11:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>http://159.13.49.45/index.php?title=Module:Delink&amp;diff=315&amp;oldid=prev</id>
		<title>Nat: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Delink&amp;diff=315&amp;oldid=prev"/>
		<updated>2025-04-07T11:02:55Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:02, 7 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key mediawiki:diff:1.41:old-314:rev-315 --&gt;
&lt;/table&gt;</summary>
		<author><name>Nat</name></author>
	</entry>
	<entry>
		<id>http://159.13.49.45/index.php?title=Module:Delink&amp;diff=314&amp;oldid=prev</id>
		<title>wikipedia&gt;Pppery: Changed protection settings for &quot;Module:Delink&quot;: Dependency of fully-protected (and on WP:CASC) Template:Fix ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))</title>
		<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Delink&amp;diff=314&amp;oldid=prev"/>
		<updated>2024-02-17T04:47:33Z</updated>

		<summary type="html">&lt;p&gt;Changed protection settings for &amp;quot;&lt;a href=&quot;/index.php/Module:Delink&quot; title=&quot;Module:Delink&quot;&gt;Module:Delink&lt;/a&gt;&amp;quot;: Dependency of fully-protected (and on &lt;a href=&quot;/index.php?title=WP:CASC&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:CASC (page does not exist)&quot;&gt;WP:CASC&lt;/a&gt;) &lt;a href=&quot;/index.php?title=Template:Fix&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Template:Fix (page does not exist)&quot;&gt;Template:Fix&lt;/a&gt; ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module de-links most wikitext.&lt;br /&gt;
&lt;br /&gt;
require(&amp;quot;strict&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local getArgs&lt;br /&gt;
&lt;br /&gt;
local function delinkReversePipeTrick(s)&lt;br /&gt;
	if s:match(&amp;quot;^%[%[|.*[|\n]&amp;quot;) then -- Check for newlines or multiple pipes.&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
	return s:match(&amp;quot;%[%[|(.*)%]%]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function delinkPipeTrick(s)&lt;br /&gt;
	-- We need to deal with colons, brackets, and commas, per [[Help:Pipe trick]].&lt;br /&gt;
	-- First, remove the text before the first colon, if any.&lt;br /&gt;
	if s:match(&amp;quot;:&amp;quot;) then&lt;br /&gt;
		s = s:match(&amp;quot;%[%[.-:(.*)|%]%]&amp;quot;)&lt;br /&gt;
	-- If there are no colons, grab all of the text apart from the square brackets and the pipe.&lt;br /&gt;
	else&lt;br /&gt;
		s = s:match(&amp;quot;%[%[(.*)|%]%]&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Next up, brackets and commas.&lt;br /&gt;
	if s:match(&amp;quot;%(.-%)$&amp;quot;) then -- Brackets trump commas.&lt;br /&gt;
		s = s:match(&amp;quot;(.-) ?%(.-%)$&amp;quot;)&lt;br /&gt;
	elseif s:match(&amp;quot;,&amp;quot;) then -- If there are no brackets, display only the text before the first comma.&lt;br /&gt;
		s = s:match(&amp;quot;(.-),.*$&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	return s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Return wikilink target |wikilinks=target&lt;br /&gt;
local function getDelinkedTarget(s)&lt;br /&gt;
	local result = s&lt;br /&gt;
	-- Deal with the reverse pipe trick.&lt;br /&gt;
	if result:match(&amp;quot;%[%[|&amp;quot;) then&lt;br /&gt;
		return delinkReversePipeTrick(result)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	result = mw.uri.decode(result, &amp;quot;PATH&amp;quot;) -- decode percent-encoded entities. Leave underscores and plus signs.&lt;br /&gt;
	result = mw.text.decode(result, true) -- decode HTML entities.&lt;br /&gt;
	&lt;br /&gt;
	-- Check for bad titles. To do this we need to find the&lt;br /&gt;
	-- title area of the link, i.e. the part before any pipes.&lt;br /&gt;
	local target_area&lt;br /&gt;
	if result:match(&amp;quot;|&amp;quot;) then -- Find if we&amp;#039;re dealing with a piped link.&lt;br /&gt;
		target_area = result:match(&amp;quot;^%[%[(.-)|.*%]%]&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		target_area = result:match(&amp;quot;^%[%[(.-)%]%]&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Check for bad characters.&lt;br /&gt;
	if mw.ustring.match(target_area, &amp;quot;[%[%]&amp;lt;&amp;gt;{}%%%c\n]&amp;quot;) and mw.ustring.match(target_area, &amp;quot;[%[%]&amp;lt;&amp;gt;{}%%%c\n]&amp;quot;) ~= &amp;quot;?&amp;quot; then&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return target_area&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getDelinkedLabel(s)&lt;br /&gt;
	local result = s&lt;br /&gt;
	-- Deal with the reverse pipe trick.&lt;br /&gt;
	if result:match(&amp;quot;%[%[|&amp;quot;) then&lt;br /&gt;
		return delinkReversePipeTrick(result)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	result = mw.uri.decode(result, &amp;quot;PATH&amp;quot;) -- decode percent-encoded entities. Leave underscores and plus signs.&lt;br /&gt;
	result = mw.text.decode(result, true) -- decode HTML entities.&lt;br /&gt;
&lt;br /&gt;
	-- Check for bad titles. To do this we need to find the&lt;br /&gt;
	-- title area of the link, i.e. the part before any pipes.&lt;br /&gt;
	local target_area&lt;br /&gt;
	if result:match(&amp;quot;|&amp;quot;) then -- Find if we&amp;#039;re dealing with a piped link.&lt;br /&gt;
		target_area = result:match(&amp;quot;^%[%[(.-)|.*%]%]&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		target_area = result:match(&amp;quot;^%[%[(.-)%]%]&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Check for bad characters.&lt;br /&gt;
	if mw.ustring.match(target_area, &amp;quot;[%[%]&amp;lt;&amp;gt;{}%%%c\n]&amp;quot;) and mw.ustring.match(target_area, &amp;quot;[%[%]&amp;lt;&amp;gt;{}%%%c\n]&amp;quot;) ~= &amp;quot;?&amp;quot; then&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Check for categories, interwikis, and files.&lt;br /&gt;
	local colon_prefix = result:match(&amp;quot;%[%[(.-):.*%]%]&amp;quot;) or &amp;quot;&amp;quot; -- Get the text before the first colon.&lt;br /&gt;
	local ns = mw.site.namespaces[colon_prefix] -- see if this is a known namespace&lt;br /&gt;
	if mw.language.isKnownLanguageTag(colon_prefix) or (ns and (ns.canonicalName == &amp;quot;File&amp;quot; or ns.canonicalName == &amp;quot;Category&amp;quot;)) then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Remove the colon if the link is using the [[Help:Colon trick]].&lt;br /&gt;
	if result:match(&amp;quot;%[%[:&amp;quot;) then&lt;br /&gt;
		result = &amp;quot;[[&amp;quot; .. result:match(&amp;quot;%[%[:(.*%]%])&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Deal with links using the [[Help:Pipe trick]].&lt;br /&gt;
	if mw.ustring.match(result, &amp;quot;^%[%[[^|]*|%]%]&amp;quot;) then&lt;br /&gt;
		return delinkPipeTrick(result)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Find the display area of the wikilink&lt;br /&gt;
	if result:match(&amp;quot;|&amp;quot;) then -- Find if we&amp;#039;re dealing with a piped link.&lt;br /&gt;
		result = result:match(&amp;quot;^%[%[.-|(.+)%]%]&amp;quot;)&lt;br /&gt;
		-- Remove new lines from the display of multiline piped links,&lt;br /&gt;
		-- where the pipe is before the first new line.&lt;br /&gt;
		result = result:gsub(&amp;quot;\n&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		result = result:match(&amp;quot;^%[%[(.-)%]%]&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function delinkURL(s)&lt;br /&gt;
	-- Assume we have already delinked internal wikilinks, and that&lt;br /&gt;
	-- we have been passed some text between two square brackets [foo].&lt;br /&gt;
	&lt;br /&gt;
	-- If the text contains a line break it is not formatted as a URL, regardless of other content.&lt;br /&gt;
	if s:match(&amp;quot;\n&amp;quot;) then&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Check if the text has a valid URL prefix and at least one valid URL character.&lt;br /&gt;
	local valid_url_prefixes = {&amp;quot;//&amp;quot;, &amp;quot;http://&amp;quot;, &amp;quot;https://&amp;quot;, &amp;quot;ftp://&amp;quot;, &amp;quot;gopher://&amp;quot;, &amp;quot;mailto:&amp;quot;, &amp;quot;news:&amp;quot;, &amp;quot;irc://&amp;quot;} &lt;br /&gt;
	local url_prefix&lt;br /&gt;
	for _ ,v in ipairs(valid_url_prefixes) do&lt;br /&gt;
		if mw.ustring.match(s, &amp;#039;^%[&amp;#039; .. v ..&amp;#039;[^&amp;quot;%s].*%]&amp;#039; ) then&lt;br /&gt;
			url_prefix = v&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Get display text&lt;br /&gt;
	if not url_prefix then&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
	s = s:match(&amp;quot;^%[&amp;quot; .. url_prefix .. &amp;quot;(.*)%]&amp;quot;) -- Grab all of the text after the URL prefix and before the final square bracket.&lt;br /&gt;
	s = s:match(&amp;#039;^.-([&amp;quot;&amp;lt;&amp;gt; ].*)&amp;#039;) or &amp;quot;&amp;quot; -- Grab all of the text after the first URL separator character (&amp;quot;&amp;lt;&amp;gt; ).&lt;br /&gt;
	s = mw.ustring.match(s, &amp;quot;^%s*(%S.*)$&amp;quot;) or &amp;quot;&amp;quot; -- If the separating character was a space, trim it off.&lt;br /&gt;
	&lt;br /&gt;
	local s_decoded = mw.text.decode(s, true)&lt;br /&gt;
	if mw.ustring.match(s_decoded, &amp;quot;%c&amp;quot;) then&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return s_decoded&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function delinkLinkClass(text, pattern, delinkFunction)&lt;br /&gt;
	if type(text) ~= &amp;quot;string&amp;quot; then&lt;br /&gt;
		error(&amp;quot;Attempt to de-link non-string input.&amp;quot;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	if type(pattern) ~= &amp;quot;string&amp;quot; or mw.ustring.sub(pattern, 1, 1) ~= &amp;quot;^&amp;quot; then&lt;br /&gt;
		error(&amp;#039;Invalid pattern detected. Patterns must begin with &amp;quot;^&amp;quot;.&amp;#039;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	-- Iterate over the text string, and replace any matched text. using the &lt;br /&gt;
	-- delink function. We need to iterate character by character rather &lt;br /&gt;
	-- than just use gsub, otherwise nested links aren&amp;#039;t detected properly.&lt;br /&gt;
	local result = &amp;quot;&amp;quot;&lt;br /&gt;
	while text ~= &amp;quot;&amp;quot; do&lt;br /&gt;
		-- Replace text using one iteration of gsub.&lt;br /&gt;
		text = mw.ustring.gsub(text, pattern, delinkFunction, 1)&lt;br /&gt;
		-- Append the left-most character to the result string.&lt;br /&gt;
		result = result .. mw.ustring.sub(text, 1, 1)&lt;br /&gt;
		text = mw.ustring.sub(text, 2, -1)&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._delink(args)&lt;br /&gt;
	local text = args[1] or &amp;quot;&amp;quot;&lt;br /&gt;
	if args.refs == &amp;quot;yes&amp;quot; then&lt;br /&gt;
		-- Remove any [[Help:Strip markers]] representing ref tags. In most situations &lt;br /&gt;
		-- this is not a good idea - only use it if you know what you are doing!&lt;br /&gt;
		text = mw.ustring.gsub(text, &amp;quot;UNIQ%w*%-ref%-%d*%-QINU&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	if args.comments ~= &amp;quot;no&amp;quot; then&lt;br /&gt;
		text = text:gsub(&amp;quot;&amp;lt;!%-%-.-%-%-&amp;gt;&amp;quot;, &amp;quot;&amp;quot;) -- Remove html comments.&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if args.wikilinks ~= &amp;quot;no&amp;quot; and args.wikilinks ~= &amp;quot;target&amp;quot; then&lt;br /&gt;
		-- De-link wikilinks and return the label portion of the wikilink.&lt;br /&gt;
		text = delinkLinkClass(text, &amp;quot;^%[%[.-%]%]&amp;quot;, getDelinkedLabel)&lt;br /&gt;
	elseif args.wikilinks == &amp;quot;target&amp;quot; then&lt;br /&gt;
		-- De-link wikilinks and return the target portions of the wikilink.&lt;br /&gt;
		text = delinkLinkClass(text, &amp;quot;^%[%[.-%]%]&amp;quot;, getDelinkedTarget)&lt;br /&gt;
	end&lt;br /&gt;
	if args.urls ~= &amp;quot;no&amp;quot; then&lt;br /&gt;
		text = delinkLinkClass(text, &amp;quot;^%[.-%]&amp;quot;, delinkURL) -- De-link URLs.&lt;br /&gt;
	end&lt;br /&gt;
	if args.whitespace ~= &amp;quot;no&amp;quot; then&lt;br /&gt;
		-- Replace single new lines with a single space, but leave double new lines&lt;br /&gt;
		-- and new lines only containing spaces or tabs before a second new line.&lt;br /&gt;
		text = mw.ustring.gsub(text, &amp;quot;([^\n \t][ \t]*)\n([ \t]*[^\n \t])&amp;quot;, &amp;quot;%1 %2&amp;quot;)&lt;br /&gt;
		text = text:gsub(&amp;quot;[ \t]+&amp;quot;, &amp;quot; &amp;quot;) -- Remove extra tabs and spaces.&lt;br /&gt;
	end&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.delink(frame)&lt;br /&gt;
	if not getArgs then&lt;br /&gt;
		getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
	end&lt;br /&gt;
	return p._delink(getArgs(frame, {wrappers = &amp;#039;Template:Delink&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Pppery</name></author>
	</entry>
</feed>