<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Adebug%2Ftrack</id>
	<title>Module:debug/track - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Adebug%2Ftrack"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:debug/track&amp;action=history"/>
	<updated>2026-04-22T00:24:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:debug/track&amp;diff=494650&amp;oldid=prev</id>
		<title>Sware: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:debug/track&amp;diff=494650&amp;oldid=prev"/>
		<updated>2026-04-21T11:21:29Z</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:21, 21 April 2026&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-mw_:diff:1.41:old-494649:rev-494650 --&gt;
&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:debug/track&amp;diff=494649&amp;oldid=prev</id>
		<title>wikt&gt;Theknightwho: Bugfix.</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:debug/track&amp;diff=494649&amp;oldid=prev"/>
		<updated>2025-06-25T23:12:15Z</updated>

		<summary type="html">&lt;p&gt;Bugfix.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- TODO 1: normalize keys with leading spaces, which don&amp;#039;t get removed when&lt;br /&gt;
-- &amp;quot;Tracking/&amp;quot; is prefixed.&lt;br /&gt;
&lt;br /&gt;
-- TODO 2: avoid weird inputs like &amp;quot;&amp;quot;, which don&amp;#039;t register as invalid since&lt;br /&gt;
-- &amp;quot;Tracking/&amp;quot; is a valid page title.&lt;br /&gt;
&lt;br /&gt;
-- TODO 3: use varargs instead of a table input, then recurse with track().&lt;br /&gt;
&lt;br /&gt;
local title_make_title_module = &amp;quot;Module:title/makeTitle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- Transclusion-based tracking as subpages of [[Wiktionary:Tracking]].&lt;br /&gt;
-- Tracked pages can be found at [[Special:WhatLinksHere/Wiktionary:Tracking/KEY]].&lt;br /&gt;
local error = error&lt;br /&gt;
local find = string.find&lt;br /&gt;
local log = mw.log&lt;br /&gt;
local sub = string.sub&lt;br /&gt;
local type = type&lt;br /&gt;
&lt;br /&gt;
local invalid_tracking_key_key = &amp;quot;debug/track/invalid key&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local function make_title(...)&lt;br /&gt;
	make_title = require(title_make_title_module)&lt;br /&gt;
	return make_title(...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local memo&lt;br /&gt;
&lt;br /&gt;
local function track(key)&lt;br /&gt;
	if not memo then&lt;br /&gt;
		memo = {}&lt;br /&gt;
	-- Return if memoized.&lt;br /&gt;
	elseif memo[key] then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	-- Throw an error if `key` isn&amp;#039;t a string.&lt;br /&gt;
	local key_type = type(key)&lt;br /&gt;
	if key_type ~= &amp;quot;string&amp;quot; then&lt;br /&gt;
		error(&amp;quot;Tracking keys supplied to [[Module:debug/track]] must be strings; received &amp;quot; .. key_type .. &amp;quot;.&amp;quot;, 3)&lt;br /&gt;
	end&lt;br /&gt;
	-- make_title returns nil for invalid titles, but &amp;quot;#&amp;quot; is treated as a&lt;br /&gt;
	-- fragment separator (e.g. &amp;quot;foo#bar&amp;quot; generates the title &amp;quot;foo&amp;quot;), so it&lt;br /&gt;
	-- needs to be manually excluded.&lt;br /&gt;
	local title = not find(key, &amp;quot;#&amp;quot;, nil, true) and make_title(4, &amp;quot;Tracking/&amp;quot; .. key)&lt;br /&gt;
	if not title then&lt;br /&gt;
		-- Track uses of invalid keys. Instead of recursing, simply memoize the&lt;br /&gt;
		-- invalid key and replace it with the &amp;#039;invalid tracking key&amp;#039; key.&lt;br /&gt;
		-- [[Special:WhatLinksHere/Wiktionary:Tracking/debug/track/invalid key]]&lt;br /&gt;
		log(&amp;quot;Invalid tracking key: &amp;quot; .. key)&lt;br /&gt;
		memo[key] = true&lt;br /&gt;
		key = invalid_tracking_key_key&lt;br /&gt;
		if memo[key] then&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
		title = make_title(4, &amp;quot;Tracking/&amp;quot; .. key)&lt;br /&gt;
	end&lt;br /&gt;
	-- Normalize the key by treating it as a subpage of &amp;quot;Tracking&amp;quot;, which gives&lt;br /&gt;
	-- the normalized title without the initial &amp;quot;Tracking/&amp;quot;. If the normalized&lt;br /&gt;
	-- form has been memoized, don&amp;#039;t transclude the page again. Otherwise,&lt;br /&gt;
	-- transclude the page using the `content` key on the title, which is the&lt;br /&gt;
	-- cheapest way to trigger transclusion, as it avoids any parser expansion&lt;br /&gt;
	-- of the target page.&lt;br /&gt;
	local normalized = sub(title.text, 10) -- excludes &amp;quot;Tracking/&amp;quot;&lt;br /&gt;
	if not memo[normalized] then&lt;br /&gt;
		title = title.content&lt;br /&gt;
		memo[normalized] = true&lt;br /&gt;
	end&lt;br /&gt;
	-- Memoize the original key.&lt;br /&gt;
	memo[key] = true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return function(input)&lt;br /&gt;
	if input == nil then&lt;br /&gt;
		error(&amp;quot;No tracking key supplied to [[Module:debug/track]].&amp;quot;, 2)&lt;br /&gt;
	elseif type(input) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
		track(input)&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	local key = input[1]&lt;br /&gt;
	if key == nil then&lt;br /&gt;
		error(&amp;quot;No tracking keys in table supplied to [[Module:debug/track]].&amp;quot;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	local i = 1&lt;br /&gt;
	repeat&lt;br /&gt;
		track(key)&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		key = input[i]&lt;br /&gt;
	until key == nil&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>wikt&gt;Theknightwho</name></author>
	</entry>
</feed>