<?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%3AItalic_title</id>
	<title>Module:Italic title - 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%3AItalic_title"/>
	<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Italic_title&amp;action=history"/>
	<updated>2026-04-03T21:35:35Z</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:Italic_title&amp;diff=2035&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:Italic_title&amp;diff=2035&amp;oldid=prev"/>
		<updated>2025-04-10T06:14: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 06:14, 10 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-2034:rev-2035 --&gt;
&lt;/table&gt;</summary>
		<author><name>Nat</name></author>
	</entry>
	<entry>
		<id>http://159.13.49.45/index.php?title=Module:Italic_title&amp;diff=2034&amp;oldid=prev</id>
		<title>wikipedia&gt;Legoktm: Replace Module:No globals with require( &quot;strict&quot; )</title>
		<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Italic_title&amp;diff=2034&amp;oldid=prev"/>
		<updated>2022-10-21T21:17:12Z</updated>

		<summary type="html">&lt;p&gt;Replace &lt;a href=&quot;/index.php?title=Module:No_globals&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:No globals (page does not exist)&quot;&gt;Module:No globals&lt;/a&gt; with require( &amp;quot;strict&amp;quot; )&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{italic title}}.&lt;br /&gt;
&lt;br /&gt;
require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
local libraryUtil = require(&amp;#039;libraryUtil&amp;#039;)&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- ItalicTitle class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local ItalicTitle = {}&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
	----------------------------------------------------------------------------&lt;br /&gt;
	-- Class attributes and functions&lt;br /&gt;
	-- Things that belong to the class are here. Things that belong to each&lt;br /&gt;
	-- object are in the constructor.&lt;br /&gt;
	----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
	-- Keys of title parts that can be italicized.&lt;br /&gt;
	local italicizableKeys = {&lt;br /&gt;
		namespace = true,&lt;br /&gt;
		title = true,&lt;br /&gt;
		dab = true,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	----------------------------------------------------------------------------&lt;br /&gt;
	-- ItalicTitle constructor&lt;br /&gt;
	-- This contains all the dynamic attributes and methods.&lt;br /&gt;
	----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
	function ItalicTitle.new()&lt;br /&gt;
		local obj = {}&lt;br /&gt;
&lt;br /&gt;
		-- Function for checking self variable in methods.&lt;br /&gt;
		local checkSelf = libraryUtil.makeCheckSelfFunction(&lt;br /&gt;
			&amp;#039;ItalicTitle&amp;#039;,&lt;br /&gt;
			&amp;#039;obj&amp;#039;,&lt;br /&gt;
			obj,&lt;br /&gt;
			&amp;#039;ItalicTitle object&amp;#039;&lt;br /&gt;
		)&lt;br /&gt;
&lt;br /&gt;
		-- Checks a key is present in a lookup table.&lt;br /&gt;
		-- Param: name - the function name.&lt;br /&gt;
		-- Param: argId - integer position of the key in the argument list.&lt;br /&gt;
		-- Param: key - the key.&lt;br /&gt;
		-- Param: lookupTable - the table to look the key up in.&lt;br /&gt;
		local function checkKey(name, argId, key, lookupTable)&lt;br /&gt;
			if not lookupTable[key] then&lt;br /&gt;
				error(string.format(&lt;br /&gt;
					&amp;quot;bad argument #%d to &amp;#039;%s&amp;#039; (&amp;#039;%s&amp;#039; is not a valid key)&amp;quot;,&lt;br /&gt;
					argId,&lt;br /&gt;
					name,&lt;br /&gt;
					key&lt;br /&gt;
				), 3)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Set up object structure.&lt;br /&gt;
		local parsed = false&lt;br /&gt;
		local categories = {}&lt;br /&gt;
		local italicizedKeys = {}&lt;br /&gt;
		local italicizedSubstrings = {}&lt;br /&gt;
&lt;br /&gt;
		-- Parses a title object into its namespace text, title, and&lt;br /&gt;
		-- disambiguation text.&lt;br /&gt;
		-- Param: options - a table of options with the following keys:&lt;br /&gt;
		--     title - the title object to parse&lt;br /&gt;
		--     ignoreDab - ignore any disambiguation parentheses&lt;br /&gt;
		-- Returns the current object.&lt;br /&gt;
		function obj:parseTitle(options)&lt;br /&gt;
			checkSelf(self, &amp;#039;parseTitle&amp;#039;)&lt;br /&gt;
			checkType(&amp;#039;parseTitle&amp;#039;, 1, options, &amp;#039;table&amp;#039;)&lt;br /&gt;
			checkTypeForNamedArg(&amp;#039;parseTitle&amp;#039;, &amp;#039;title&amp;#039;, options.title, &amp;#039;table&amp;#039;)&lt;br /&gt;
			local title = options.title&lt;br /&gt;
		&lt;br /&gt;
			-- Title and dab text&lt;br /&gt;
			local prefix, parentheses&lt;br /&gt;
			if not options.ignoreDab then&lt;br /&gt;
				prefix, parentheses = mw.ustring.match(&lt;br /&gt;
					title.text,&lt;br /&gt;
					&amp;#039;^(.+) %(([^%(%)]+)%)$&amp;#039;&lt;br /&gt;
				)&lt;br /&gt;
			end&lt;br /&gt;
			if prefix and parentheses then&lt;br /&gt;
				self.title = prefix&lt;br /&gt;
				self.dab = parentheses&lt;br /&gt;
			else&lt;br /&gt;
				self.title = title.text&lt;br /&gt;
			end&lt;br /&gt;
		&lt;br /&gt;
			-- Namespace&lt;br /&gt;
			local namespace = mw.site.namespaces[title.namespace].name&lt;br /&gt;
			if namespace and #namespace &amp;gt;= 1 then&lt;br /&gt;
				self.namespace = namespace&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Register the object as having parsed a title.&lt;br /&gt;
			parsed = true&lt;br /&gt;
		&lt;br /&gt;
			return self&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Italicizes part of the title.&lt;br /&gt;
		-- Param: key - the key of the title part to be italicized. Possible&lt;br /&gt;
		-- keys are contained in the italicizableKeys table.&lt;br /&gt;
		-- Returns the current object.&lt;br /&gt;
		function obj:italicize(key)&lt;br /&gt;
			checkSelf(self, &amp;#039;italicize&amp;#039;)&lt;br /&gt;
			checkType(&amp;#039;italicize&amp;#039;, 1, key, &amp;#039;string&amp;#039;)&lt;br /&gt;
			checkKey(&amp;#039;italicize&amp;#039;, 1, key, italicizableKeys)&lt;br /&gt;
			italicizedKeys[key] = true&lt;br /&gt;
			return self&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Un-italicizes part of the title.&lt;br /&gt;
		-- Param: key - the key of the title part to be un-italicized. Possible&lt;br /&gt;
		-- keys are contained in the italicizableKeys table.&lt;br /&gt;
		-- Returns the current object.&lt;br /&gt;
		function obj:unitalicize(key)&lt;br /&gt;
			checkSelf(self, &amp;#039;unitalicize&amp;#039;)&lt;br /&gt;
			checkType(&amp;#039;unitalicize&amp;#039;, 1, key, &amp;#039;string&amp;#039;)&lt;br /&gt;
			checkKey(&amp;#039;unitalicize&amp;#039;, 1, key, italicizableKeys)&lt;br /&gt;
			italicizedKeys[key] = nil&lt;br /&gt;
			return self&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Italicizes a substring in the title. This only affects the main part&lt;br /&gt;
		-- of the title, not the namespace or the disambiguation text.&lt;br /&gt;
		-- Param: s - the substring to be italicized.&lt;br /&gt;
		-- Returns the current object.&lt;br /&gt;
		function obj:italicizeSubstring(s)&lt;br /&gt;
			checkSelf(self, &amp;#039;italicizeSubstring&amp;#039;)&lt;br /&gt;
			checkType(&amp;#039;italicizeSubstring&amp;#039;, 1, s, &amp;#039;string&amp;#039;)&lt;br /&gt;
			italicizedSubstrings[s] = true&lt;br /&gt;
			return self&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Un-italicizes a substring in the title. This only affects the main&lt;br /&gt;
		-- part of the title, not the namespace or the disambiguation text.&lt;br /&gt;
		-- Param: s - the substring to be un-italicized.&lt;br /&gt;
		-- Returns the current object.&lt;br /&gt;
		function obj:unitalicizeSubstring(s)&lt;br /&gt;
			checkSelf(self, &amp;#039;unitalicizeSubstring&amp;#039;)&lt;br /&gt;
			checkType(&amp;#039;unitalicizeSubstring&amp;#039;, 1, s, &amp;#039;string&amp;#039;)&lt;br /&gt;
			italicizedSubstrings[s] = nil&lt;br /&gt;
			return self&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Renders the object into a page name. If no title has yet been parsed,&lt;br /&gt;
		-- the current title is used.&lt;br /&gt;
		-- Returns string&lt;br /&gt;
		function obj:renderTitle()&lt;br /&gt;
			checkSelf(self, &amp;#039;renderTitle&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
			-- Italicizes a string&lt;br /&gt;
			-- Param: s - the string to italicize&lt;br /&gt;
			-- Returns string.&lt;br /&gt;
			local function italicize(s)&lt;br /&gt;
				assert(type(s) == &amp;#039;string&amp;#039;, &amp;#039;s was not a string&amp;#039;)&lt;br /&gt;
				assert(s ~= &amp;#039;&amp;#039;, &amp;#039;s was the empty string&amp;#039;)&lt;br /&gt;
				return string.format(&amp;#039;&amp;lt;i&amp;gt;%s&amp;lt;/i&amp;gt;&amp;#039;, s)&lt;br /&gt;
			end&lt;br /&gt;
		&lt;br /&gt;
			-- Escape characters in a string that are magic in Lua patterns.&lt;br /&gt;
			-- Param: pattern - the pattern to escape&lt;br /&gt;
			-- Returns string.&lt;br /&gt;
			local function escapeMagicCharacters(s)&lt;br /&gt;
				assert(type(s) == &amp;#039;string&amp;#039;, &amp;#039;s was not a string&amp;#039;)&lt;br /&gt;
				return s:gsub(&amp;#039;%p&amp;#039;, &amp;#039;%%%0&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- If a title hasn&amp;#039;t been parsed yet, parse the current title.&lt;br /&gt;
			if not parsed then&lt;br /&gt;
				self:parseTitle{title = mw.title.getCurrentTitle()}&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Italicize the different parts of the title and store them in a&lt;br /&gt;
			-- titleParts table to be joined together later.&lt;br /&gt;
			local titleParts = {}&lt;br /&gt;
&lt;br /&gt;
			-- Italicize the italicizable keys.&lt;br /&gt;
			for key in pairs(italicizableKeys) do&lt;br /&gt;
				if self[key] then&lt;br /&gt;
					if italicizedKeys[key] then&lt;br /&gt;
						titleParts[key] = italicize(self[key])&lt;br /&gt;
					else&lt;br /&gt;
						titleParts[key] = self[key]&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Italicize substrings. If there are any substrings to be&lt;br /&gt;
			-- italicized then start from the raw title, as this overrides any&lt;br /&gt;
			-- italicization of the main part of the title.&lt;br /&gt;
			if next(italicizedSubstrings) then&lt;br /&gt;
				titleParts.title = self.title&lt;br /&gt;
				for s in pairs(italicizedSubstrings) do&lt;br /&gt;
					local pattern = escapeMagicCharacters(s)&lt;br /&gt;
					local italicizedTitle, nReplacements = titleParts.title:gsub(&lt;br /&gt;
						pattern,&lt;br /&gt;
						italicize&lt;br /&gt;
					)&lt;br /&gt;
					titleParts.title = italicizedTitle&lt;br /&gt;
&lt;br /&gt;
					-- If we didn&amp;#039;t make any replacements then it means that we&lt;br /&gt;
					-- have been passed a bad substring or that the page has&lt;br /&gt;
					-- been moved to a bad title, so add a tracking category.&lt;br /&gt;
					if nReplacements &amp;lt; 1 then&lt;br /&gt;
						categories[&amp;#039;Pages using italic title with no matching string&amp;#039;] = true&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Assemble the title together from the parts.&lt;br /&gt;
			local ret = &amp;#039;&amp;#039;&lt;br /&gt;
			if titleParts.namespace then&lt;br /&gt;
				ret = ret .. titleParts.namespace .. &amp;#039;:&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			ret = ret .. titleParts.title&lt;br /&gt;
			if titleParts.dab then&lt;br /&gt;
				ret = ret .. &amp;#039; (&amp;#039; .. titleParts.dab .. &amp;#039;)&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			return ret&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Returns an expanded DISPLAYTITLE parser function called with the&lt;br /&gt;
		-- result of obj:renderTitle, plus any other optional arguments.&lt;br /&gt;
		-- Returns string&lt;br /&gt;
		function obj:renderDisplayTitle(...)&lt;br /&gt;
			checkSelf(self, &amp;#039;renderDisplayTitle&amp;#039;)&lt;br /&gt;
			return mw.getCurrentFrame():callParserFunction(&lt;br /&gt;
				&amp;#039;DISPLAYTITLE&amp;#039;,&lt;br /&gt;
				self:renderTitle(),&lt;br /&gt;
				...&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Returns an expanded DISPLAYTITLE parser function called with the&lt;br /&gt;
		-- result of obj:renderTitle, plus any other optional arguments, plus&lt;br /&gt;
		-- any tracking categories.&lt;br /&gt;
		-- Returns string&lt;br /&gt;
		function obj:render(...)&lt;br /&gt;
			checkSelf(self, &amp;#039;render&amp;#039;)&lt;br /&gt;
			local ret = self:renderDisplayTitle(...)&lt;br /&gt;
			for cat in pairs(categories) do&lt;br /&gt;
				ret = ret .. string.format(&lt;br /&gt;
					&amp;#039;[[Category:%s]]&amp;#039;,&lt;br /&gt;
					cat&lt;br /&gt;
				)&lt;br /&gt;
			end&lt;br /&gt;
			return ret&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		return obj&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Exports&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function getArgs(frame, wrapper)&lt;br /&gt;
	assert(type(wrapper) == &amp;#039;string&amp;#039;, &amp;#039;wrapper was not a string&amp;#039;)&lt;br /&gt;
	return require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, {&lt;br /&gt;
		wrappers = wrapper&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Main function for {{italic title}}&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	checkType(&amp;#039;_main&amp;#039;, 1, args, &amp;#039;table&amp;#039;)&lt;br /&gt;
	local italicTitle = ItalicTitle.new()&lt;br /&gt;
	italicTitle:parseTitle{&lt;br /&gt;
		title = mw.title.getCurrentTitle(),&lt;br /&gt;
		ignoreDab = yesno(args.all, false)&lt;br /&gt;
	}&lt;br /&gt;
	if args.string then&lt;br /&gt;
		italicTitle:italicizeSubstring(args.string)&lt;br /&gt;
	else&lt;br /&gt;
		italicTitle:italicize(&amp;#039;title&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	return italicTitle:render(args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	return p._main(getArgs(frame, &amp;#039;Template:Italic title&amp;#039;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._dabonly(args)&lt;br /&gt;
	return ItalicTitle.new()&lt;br /&gt;
		:italicize(&amp;#039;dab&amp;#039;)&lt;br /&gt;
		:render(args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.dabonly(frame)&lt;br /&gt;
	return p._dabonly(getArgs(frame, &amp;#039;Template:Italic dab&amp;#039;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Legoktm</name></author>
	</entry>
</feed>