<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AApplyLinkAnnotations</id>
	<title>Module:ApplyLinkAnnotations - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AApplyLinkAnnotations"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:ApplyLinkAnnotations&amp;action=history"/>
	<updated>2026-05-27T05:45:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:ApplyLinkAnnotations&amp;diff=135230&amp;oldid=prev</id>
		<title>imported&gt;N8wilson: Adding possibility for deep asterisk linking; testcases in sandbox passing (they fail in the **correct** way for a known caveat of current version)</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:ApplyLinkAnnotations&amp;diff=135230&amp;oldid=prev"/>
		<updated>2022-03-07T18:39:47Z</updated>

		<summary type="html">&lt;p&gt;Adding possibility for deep asterisk linking; testcases in sandbox passing (they fail in the **correct** way for a known caveat of current version)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {};&lt;br /&gt;
&lt;br /&gt;
local regex = &amp;quot;(:*%**)%*%s*%[%[([^%]|:][^%]:]*[^%]|:])%]%]%s*&amp;quot;&lt;br /&gt;
local repl  = &amp;quot;%1* {{Annotated link |%2}}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function p.replaceLinksInUnorderedList(markup)&lt;br /&gt;
  -- provided for convenience to make console testing easier for development&lt;br /&gt;
  --&lt;br /&gt;
  -- matches any wikilinks that are&lt;br /&gt;
  --    1. at the beginning of a list item &lt;br /&gt;
  --    2. with no existing annotation (or any text) following them&lt;br /&gt;
  --&lt;br /&gt;
  -- must run twice because match utilizes the newlines on *both* sides&lt;br /&gt;
  -- of wikilinks and thus, &amp;quot;consumes&amp;quot; those chars during the first match&lt;br /&gt;
  -- such that every-other line is ineligible for matching until the second &lt;br /&gt;
  -- run. (which does the same thing but for all the other lines)&lt;br /&gt;
&lt;br /&gt;
  -- Test case(s?):&lt;br /&gt;
  -- =p.replaceLinksInUnorderedList(&amp;quot;\n*[[TEst|teST]] \n:* [[name]]\n::*[[link]] - with existing annotation\n::* [[for|a friend]]  \n*[[t]]\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  local anls, cnt1, cnt2&lt;br /&gt;
&lt;br /&gt;
  -- pattern and replacement updated locally to require newlines &lt;br /&gt;
  -- on both sides&lt;br /&gt;
  local regex_line = &amp;#039;\n&amp;#039; .. regex .. &amp;#039;\n&amp;#039;&lt;br /&gt;
  local repl_line  = &amp;#039;\n&amp;#039; .. repl  .. &amp;#039;\n&amp;#039;&lt;br /&gt;
&lt;br /&gt;
  anls, cnt1 = mw.ustring.gsub(markup, regex_line, repl_line)&lt;br /&gt;
  anls, cnt2 = mw.ustring.gsub(anls,   regex_line, repl_line)&lt;br /&gt;
&lt;br /&gt;
  mw.log(&amp;quot;Replaced &amp;quot; .. cnt1+cnt2 .. &amp;quot; links without existing annotations&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  return anls&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.bySubstitutionInUnorderedList(frame)&lt;br /&gt;
  return p.replaceLinksInUnorderedList(frame.args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._testline(line)&lt;br /&gt;
  -- testing function used to evaluate a single line against the pattern(regex)&lt;br /&gt;
  -- signature designed to accommodate Module:UnitTests:equals&lt;br /&gt;
  -- so frame args are NOT extracted, a raw string is expected&lt;br /&gt;
  local res, cnt = mw.ustring.gsub(line, &amp;#039;^&amp;#039;..regex..&amp;#039;$&amp;#039;, repl)&lt;br /&gt;
  return res&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;N8wilson</name></author>
	</entry>
</feed>