<?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%3Areferences</id>
	<title>Module:references - 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%3Areferences"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:references&amp;action=history"/>
	<updated>2026-04-12T20:33:52Z</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:references&amp;diff=435185&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local export = {}  local rsplit = mw.text.split  --[==[ Parse a references spec as used in the {{para|ref}} param to {{tl|IPA}}, {{tl|IPAchar}}, {{tl|homophones}}, {{tl|rhymes}}, etc. and soon the {{para|f&lt;var&gt;N&lt;/var&gt;ref}} param to {{tl|head}}. `parse_err` is a function of one argument to throw an error with the specified argument as the error message; defaults to `error`.  Multiple references are separated by `!!!` (optionally with spaces around it), and the equivalent...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:references&amp;diff=435185&amp;oldid=prev"/>
		<updated>2025-01-26T13:58:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local rsplit = mw.text.split  --[==[ Parse a references spec as used in the {{para|ref}} param to {{tl|IPA}}, {{tl|IPAchar}}, {{tl|homophones}}, {{tl|rhymes}}, etc. and soon the {{para|f&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;ref}} param to {{tl|head}}. `parse_err` is a function of one argument to throw an error with the specified argument as the error message; defaults to `error`.  Multiple references are separated by `!!!` (optionally with spaces around it), and the equivalent...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local export = {}&lt;br /&gt;
&lt;br /&gt;
local rsplit = mw.text.split&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Parse a references spec as used in the {{para|ref}} param to {{tl|IPA}}, {{tl|IPAchar}}, {{tl|homophones}},&lt;br /&gt;
{{tl|rhymes}}, etc. and soon the {{para|f&amp;lt;var&amp;gt;N&amp;lt;/var&amp;gt;ref}} param to {{tl|head}}. `parse_err` is a function of one&lt;br /&gt;
argument to throw an error with the specified argument as the error message; defaults to `error`.&lt;br /&gt;
&lt;br /&gt;
Multiple references are separated by `!!!` (optionally with spaces around it), and the equivalent of&lt;br /&gt;
`&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;bendo&amp;quot;&amp;gt;{{R:it:DiPI|bendo}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{R:it:Olivetti}}&amp;lt;/ref&amp;gt;&amp;lt;/nowiki&amp;gt;` can be specified using a&lt;br /&gt;
syntax like the following:&lt;br /&gt;
&lt;br /&gt;
{ {{IPA|it|ˈben.do|ˈbɛn.do|ref2={{R:it:DiPI|bendo}}&amp;lt;&amp;lt;name:bendo&amp;gt;&amp;gt; !!! {{R:it:Olivetti}}}}}&lt;br /&gt;
&lt;br /&gt;
To include a group as in `&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;bendo&amp;quot; group=&amp;quot;pron&amp;quot;&amp;gt;...&amp;lt;/ref&amp;gt;&amp;lt;/nowiki&amp;gt;` use:&lt;br /&gt;
&lt;br /&gt;
{ {{IPA|it|ˈben.do|ˈbɛn.do|ref2={{R:it:DiPI|bendo}}&amp;lt;&amp;lt;name:bendo&amp;gt;&amp;gt;&amp;lt;&amp;lt;group:pron&amp;gt;&amp;gt;}}}&lt;br /&gt;
&lt;br /&gt;
To reference a prior name, as in `&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;bendo&amp;quot;/&amp;gt;&amp;lt;/nowiki&amp;gt;`, leave the reference text blank:&lt;br /&gt;
&lt;br /&gt;
{ {{IPA|it|ˈben.do|ˈbɛn.do|ref2=&amp;lt;&amp;lt;name:bendo&amp;gt;&amp;gt;}}}&lt;br /&gt;
&lt;br /&gt;
Similarly, to reference a prior name in a particular group, as in `&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;bendo&amp;quot; group=&amp;quot;pron&amp;quot;/&amp;gt;&amp;lt;/nowiki&amp;gt;`, use:&lt;br /&gt;
&lt;br /&gt;
{ {{IPA|it|ˈben.do|ˈbɛn.do|ref2=&amp;lt;&amp;lt;name:bendo&amp;gt;&amp;gt;&amp;lt;&amp;lt;group:pron&amp;gt;&amp;gt;}}}&lt;br /&gt;
&lt;br /&gt;
The return value consists of a list of objects of the form { {text = TEXT, name = NAME, group = GROUP}}.&lt;br /&gt;
This is the same format as is expected in the `part.refs` in [[Module:headword]] and `item.refs` in&lt;br /&gt;
[[Module:IPA]].&lt;br /&gt;
]==]&lt;br /&gt;
function export.parse_references(text, parse_err)&lt;br /&gt;
	parse_err = parse_err or error&lt;br /&gt;
	local refs = {}&lt;br /&gt;
	local raw_notes = rsplit(text, &amp;quot;%s*!!!%s*&amp;quot;)&lt;br /&gt;
	for _, raw_note in ipairs(raw_notes) do&lt;br /&gt;
		local note&lt;br /&gt;
		if raw_note:find(&amp;quot;&amp;lt;&amp;lt;&amp;quot;) then&lt;br /&gt;
			local splitvals = require(&amp;quot;Module:string utilities&amp;quot;).split(raw_note, &amp;quot;(&amp;lt;&amp;lt;[a-z]+:.-&amp;gt;&amp;gt;)&amp;quot;)&lt;br /&gt;
			note = {text = splitvals[1]}&lt;br /&gt;
			for i = 2, #splitvals, 2 do&lt;br /&gt;
				local key, value = splitvals[i]:match(&amp;quot;^&amp;lt;&amp;lt;([a-z]+):(.*)&amp;gt;&amp;gt;$&amp;quot;)&lt;br /&gt;
				if not key then&lt;br /&gt;
					parse_err(&amp;quot;Internal error: Can&amp;#039;t parse &amp;quot; .. splitvals[i])&lt;br /&gt;
				end&lt;br /&gt;
				if key == &amp;quot;name&amp;quot; or key == &amp;quot;group&amp;quot; then&lt;br /&gt;
					note[key] = value&lt;br /&gt;
				else&lt;br /&gt;
					parse_err(&amp;quot;Unrecognized key &amp;#039;&amp;quot; .. key .. &amp;quot;&amp;#039; in &amp;quot; .. splitvals[i])&lt;br /&gt;
				end&lt;br /&gt;
				if splitvals[i + 1] ~= &amp;quot;&amp;quot; then&lt;br /&gt;
					parse_err(&amp;quot;Extraneous text &amp;#039;&amp;quot; .. splitvals[i + 1] .. &amp;quot;&amp;#039; after &amp;quot; .. splitvals[i])&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			note = raw_note&lt;br /&gt;
		end&lt;br /&gt;
		table.insert(refs, note)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return refs&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Format a list of reference specs, using a parser function. The return string contains a footnote number that hyperlinks&lt;br /&gt;
to the actual reference, located in the `&amp;lt;nowiki&amp;gt;&amp;lt;references /&amp;gt;&amp;lt;/nowiki&amp;gt;` section. The format an individual reference&lt;br /&gt;
spec is either a string containing the reference text (typically a call to a citation template such as {{tl|cite-book}},&lt;br /&gt;
or a template wrapping such a call), or an object with fields `text` (the reference text), `name` (the name of the&lt;br /&gt;
reference, as in `&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;foo&amp;quot;&amp;gt;...&amp;lt;/ref&amp;gt;&amp;lt;/nowiki&amp;gt;` or `&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;foo&amp;quot; /&amp;gt;&amp;lt;/nowiki&amp;gt;`) and/or `group`&lt;br /&gt;
(the group of the reference, as in `&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;foo&amp;quot; group=&amp;quot;bar&amp;quot;&amp;gt;...&amp;lt;/ref&amp;gt;&amp;lt;/nowiki&amp;gt;` or&lt;br /&gt;
`&amp;lt;nowiki&amp;gt;&amp;lt;ref name=&amp;quot;foo&amp;quot; group=&amp;quot;bar&amp;quot;/&amp;gt;&amp;lt;/nowiki&amp;gt;`).&lt;br /&gt;
]==]&lt;br /&gt;
function export.format_references(refspecs)&lt;br /&gt;
	local refs = {}&lt;br /&gt;
	for _, refspec in ipairs(refspecs) do&lt;br /&gt;
		if type(refspec) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
			refspec = {text = refspec}&lt;br /&gt;
		end&lt;br /&gt;
		local refargs&lt;br /&gt;
		if refspec.name or refspec.group then&lt;br /&gt;
			refargs = {name = refspec.name, group = refspec.group}&lt;br /&gt;
		end&lt;br /&gt;
		table.insert(refs, mw.getCurrentFrame():extensionTag(&amp;quot;ref&amp;quot;, refspec.text, refargs))&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(refs)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>