<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tes5.st34an.tech/index.php?action=history&amp;feed=atom&amp;title=Module%3AUsex</id>
	<title>Module:Usex - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tes5.st34an.tech/index.php?action=history&amp;feed=atom&amp;title=Module%3AUsex"/>
	<link rel="alternate" type="text/html" href="https://tes5.st34an.tech/index.php?title=Module:Usex&amp;action=history"/>
	<updated>2026-04-17T18:49:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://tes5.st34an.tech/index.php?title=Module:Usex&amp;diff=3362&amp;oldid=prev</id>
		<title>imported&gt;Vaxjedi at 16:18, 12 March 2024</title>
		<link rel="alternate" type="text/html" href="https://tes5.st34an.tech/index.php?title=Module:Usex&amp;diff=3362&amp;oldid=prev"/>
		<updated>2024-03-12T16:18:14Z</updated>

		<summary type="html">&lt;p&gt;&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 debug_track_module = &amp;quot;Module:debug/track&amp;quot;&lt;br /&gt;
local links_module = &amp;quot;Module:links&amp;quot;&lt;br /&gt;
local script_utilities_module = &amp;quot;Module:script utilities&amp;quot;&lt;br /&gt;
local usex_data_module = &amp;quot;Module:usex/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local rsubn = mw.ustring.gsub&lt;br /&gt;
local rsplit = mw.text.split&lt;br /&gt;
local rfind = mw.ustring.find&lt;br /&gt;
local uupper = mw.ustring.upper&lt;br /&gt;
local u = mw.ustring.char&lt;br /&gt;
&lt;br /&gt;
local translit_data = mw.loadData(&amp;quot;Module:transliteration/data&amp;quot;)&lt;br /&gt;
local needs_translit = translit_data[1]&lt;br /&gt;
&lt;br /&gt;
local BRACKET_SUB = u(0xFFF0)&lt;br /&gt;
local original_text = &amp;quot;&amp;lt;small&amp;gt;&amp;#039;&amp;#039;original:&amp;#039;&amp;#039;&amp;lt;/small&amp;gt; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- microformat2 classes, see https://phabricator.wikimedia.org/T138709&lt;br /&gt;
local css_classes = {&lt;br /&gt;
	container_ux = &amp;#039;h-usage-example&amp;#039;,&lt;br /&gt;
	container_quotation = &amp;#039;h-quotation&amp;#039;,&lt;br /&gt;
	example = &amp;#039;e-example&amp;#039;,&lt;br /&gt;
	quotation = &amp;#039;e-quotation&amp;#039;,&lt;br /&gt;
	quotation_with_citation = &amp;#039;e-quotation cited-passage&amp;#039;,&lt;br /&gt;
	translation = &amp;#039;e-translation&amp;#039;,&lt;br /&gt;
	-- The following are added by [[Module:script utilities]], using [[Module:script utilities/data]]&lt;br /&gt;
--	transliteration = &amp;#039;e-transliteration&amp;#039;,	&lt;br /&gt;
--	transcription = &amp;#039;e-transcription&amp;#039;,&lt;br /&gt;
	normalization = &amp;#039;e-normalization&amp;#039;,&lt;br /&gt;
	literally = &amp;#039;e-literally&amp;#039;,&lt;br /&gt;
	source = &amp;#039;e-source&amp;#039;,&lt;br /&gt;
	footer = &amp;#039;e-footer&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- helper functions&lt;br /&gt;
&lt;br /&gt;
local function track(page)&lt;br /&gt;
	require(debug_track_module)(&amp;quot;usex/&amp;quot; .. page)&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- version of rsubn() that discards all but the first return value&lt;br /&gt;
local function rsub(term, foo, bar)&lt;br /&gt;
	local retval = rsubn(term, foo, bar)&lt;br /&gt;
	return retval&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function wrap(tag, class, text, lang)&lt;br /&gt;
	if lang then&lt;br /&gt;
		lang = &amp;#039; lang=&amp;quot;&amp;#039; .. lang .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		lang = &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if text and class then&lt;br /&gt;
		return table.concat{&amp;#039;&amp;lt;&amp;#039;, tag, &amp;#039; class=&amp;quot;&amp;#039;, class, &amp;#039;&amp;quot;&amp;#039;, lang, &amp;#039;&amp;gt;&amp;#039;, text, &amp;#039;&amp;lt;/&amp;#039;, tag, &amp;#039;&amp;gt;&amp;#039;}&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function span(class, text) return wrap(&amp;#039;span&amp;#039;, class, text) end&lt;br /&gt;
local function div(class, text) return wrap(&amp;#039;div&amp;#039;, class, text) end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Apply the substitutions in `subst` (from the {{para|subst}} parameter or similar) to the example or quotation in&lt;br /&gt;
`usex` after removing links, returning the resulting text. `track`, if supplied, is a function of one argument that is&lt;br /&gt;
used to insert tracking categories: one for any call to this function, another if a single / is used in the `subst`&lt;br /&gt;
argument.&lt;br /&gt;
]==]&lt;br /&gt;
function export.apply_subst(usex, subst, track)&lt;br /&gt;
	local subbed_usex = require(links_module).remove_links(usex)&lt;br /&gt;
	local function do_track(page)&lt;br /&gt;
		if track then&lt;br /&gt;
			track(page)&lt;br /&gt;
		end&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if subst then&lt;br /&gt;
		-- [[Special:WhatLinksHere/Template:tracking/usex/subst]]&lt;br /&gt;
		do_track(&amp;quot;subst&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		subst = rsplit(subst, &amp;quot;,&amp;quot;)&lt;br /&gt;
		for _, subpair in ipairs(subst) do&lt;br /&gt;
			-- [[Special:WhatLinksHere/Template:tracking/usex/subst-single-slash]]&lt;br /&gt;
			local subsplit = rsplit(subpair, rfind(subpair, &amp;quot;//&amp;quot;) and &amp;quot;//&amp;quot; or do_track(&amp;quot;subst-single-slash&amp;quot;) and &amp;quot;/&amp;quot;)&lt;br /&gt;
			subbed_usex = rsub(subbed_usex, subsplit[1], subsplit[2])&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return subbed_usex&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[=[&lt;br /&gt;
Process parameters for usex text (either the primary text or the original text) and associated annotations. On input,&lt;br /&gt;
the following fields are recognized in `data` (all are optional except as marked):&lt;br /&gt;
&lt;br /&gt;
* `lang`: Language object of text; may be an etymology language (REQUIRED).&lt;br /&gt;
* `termlang`: The language object of the term being illustrated, which may be different from the language of the main&lt;br /&gt;
			  quotation text and should always be based off of the main text, not the original text. Used for&lt;br /&gt;
			  categories. May be an etymology language (REQUIRED).&lt;br /&gt;
* `quotelang`: The language object of the main quotation, which should always be based off of the main quotation text,&lt;br /&gt;
			   not the original text. Used for categories. May be an etymology language (REQUIRED).&lt;br /&gt;
* `usex`: Text of usex/quotation.&lt;br /&gt;
* `sc`: Script object of text.&lt;br /&gt;
* `tr`: Manual transliteration.&lt;br /&gt;
* `ts`: Transcription.&lt;br /&gt;
* `norm`: Normalized version of text.&lt;br /&gt;
* `normsc`: Script object of normalized version of text, or &amp;quot;auto&amp;quot;.&lt;br /&gt;
* `subst`: String of substitutions for transliteration purposes.&lt;br /&gt;
* `quote`: If non-nil, this is a quotation (using {{tl|quote}} or {{tl|quote-*}}) instead of a usage example (using&lt;br /&gt;
  {{tl|usex}}). If it has the specific value &amp;quot;quote-meta&amp;quot;, this is a quotation with citation (invoked from&lt;br /&gt;
  {{tl|quote-*}}). This controls the CSS class used to display the quotation, as well as the face used to tag the usex&lt;br /&gt;
  (which in turn results in the usex being upright text if a quotation, and italic text if a usage example).&lt;br /&gt;
* `title`: Title object of the current page (REQUIRED).&lt;br /&gt;
* `q`: List of left qualifiers.&lt;br /&gt;
* `qq`: List of right qualifiers.&lt;br /&gt;
* `ref`: String to display directly after any right qualifier, with no space. (FIXME: Should be converted into&lt;br /&gt;
         an actual ref.)&lt;br /&gt;
* `nocat`: Overall `data.nocat` value.&lt;br /&gt;
* `categories`: List to insert categories into (REQUIRED).&lt;br /&gt;
* `example_type`: Either &amp;quot;quotation&amp;quot; (if `quote` specified) or &amp;quot;usage example&amp;quot; (otherwise) (REQUIRED).&lt;br /&gt;
&lt;br /&gt;
On output, return an object with four fields:&lt;br /&gt;
* `usex`: Formatted usex, including qualifiers attached to both sides and `ref` attached to the right. Always specified.&lt;br /&gt;
* `tr`: Formatted transliteration; may be nil.&lt;br /&gt;
* `ts`: Formatted transcription; may be nil.&lt;br /&gt;
* `norm`: Formatted normalized version of usex; may be nil.&lt;br /&gt;
]=]&lt;br /&gt;
local function process_usex_text(data)&lt;br /&gt;
	local lang = data.lang&lt;br /&gt;
	local termlang = data.termlang&lt;br /&gt;
	local quotelang = data.quotelang&lt;br /&gt;
	local usex = data.usex&lt;br /&gt;
	local sc = data.sc&lt;br /&gt;
	local tr = data.tr&lt;br /&gt;
	local ts = data.ts&lt;br /&gt;
	local norm = data.norm&lt;br /&gt;
	local normsc = data.normsc&lt;br /&gt;
	local subst = data.subst&lt;br /&gt;
	local quote = data.quote&lt;br /&gt;
	local leftq = data.q&lt;br /&gt;
	local rightq = data.qq&lt;br /&gt;
	local ref = data.ref&lt;br /&gt;
	local nocat = data.nocat&lt;br /&gt;
	local categories = data.categories&lt;br /&gt;
	local example_type = data.example_type&lt;br /&gt;
	local title = data.title&lt;br /&gt;
&lt;br /&gt;
	if normsc == &amp;quot;auto&amp;quot; then&lt;br /&gt;
		normsc = nil&lt;br /&gt;
	elseif not normsc then&lt;br /&gt;
		normsc = sc&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not sc then&lt;br /&gt;
		sc = lang:findBestScript(usex)&lt;br /&gt;
	end&lt;br /&gt;
	if not normsc and norm then&lt;br /&gt;
		normsc = lang:findBestScript(norm)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local langcode = lang:getNonEtymologicalCode()&lt;br /&gt;
&lt;br /&gt;
	-- tr=- means omit transliteration altogether&lt;br /&gt;
	if tr == &amp;quot;-&amp;quot; then&lt;br /&gt;
		tr = nil&lt;br /&gt;
	else&lt;br /&gt;
		-- Try to auto-transliterate.&lt;br /&gt;
		if not tr then&lt;br /&gt;
			-- First, try transliterating the normalization, if supplied.&lt;br /&gt;
			if norm and normsc and not normsc:getCode():find(&amp;quot;Lat&amp;quot;) then -- Latn, Latf, Latg, pjt-Latn&lt;br /&gt;
				local subbed_norm = export.apply_subst(norm, subst, track)&lt;br /&gt;
				tr = (lang:transliterate(subbed_norm, normsc))&lt;br /&gt;
			end&lt;br /&gt;
			-- If no normalization, or the normalization is in a Latin script, or the transliteration of the&lt;br /&gt;
			-- normalization failed, fall back to transliterating the usex.&lt;br /&gt;
			if not tr then&lt;br /&gt;
				local subbed_usex = export.apply_subst(usex, subst, track)&lt;br /&gt;
				tr = (lang:transliterate(subbed_usex, sc))&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- If the language doesn&amp;#039;t have capitalization and is specified in [[Module:usex/data]], then capitalize any sentences.&lt;br /&gt;
			-- Exclamation marks and question marks need to be unescaped then re-escaped.&lt;br /&gt;
			if tr and mw.loadData(usex_data_module).capitalize_sentences[langcode] then&lt;br /&gt;
				tr = tr:gsub(&amp;quot;&amp;amp;#x21;&amp;quot;, &amp;quot;!&amp;quot;)&lt;br /&gt;
					:gsub(&amp;quot;&amp;amp;#x3F;&amp;quot;, &amp;quot;?&amp;quot;)&lt;br /&gt;
				tr = rsub(tr, &amp;quot;%f[^%z%p%s](.)(.-[%.%?!‽])&amp;quot;, function(m1, m2)&lt;br /&gt;
					return uupper(m1) .. m2&lt;br /&gt;
				end)&lt;br /&gt;
				tr = tr:gsub(&amp;quot;!&amp;quot;, &amp;quot;&amp;amp;#x21;&amp;quot;)&lt;br /&gt;
					:gsub(&amp;quot;%?&amp;quot;, &amp;quot;&amp;amp;#x3F;&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- If there is still no transliteration, then add a cleanup category.&lt;br /&gt;
		if not tr and needs_translit[langcode] then&lt;br /&gt;
			table.insert(categories, (&amp;quot;Requests for transliteration of %s %ss&amp;quot;):format(quotelang:getCanonicalName(),&lt;br /&gt;
				example_type))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if tr then&lt;br /&gt;
		tr = require(script_utilities_module).tag_translit(tr, langcode, &amp;quot;usex&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	if ts then&lt;br /&gt;
		ts = require(script_utilities_module).tag_transcription(ts, langcode, &amp;quot;usex&amp;quot;)&lt;br /&gt;
		ts = &amp;quot;/&amp;quot; .. ts .. &amp;quot;/&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function do_language_and_script_tagging(usex, lang, sc, css_class)&lt;br /&gt;
		usex = require(links_module).embedded_language_links{term = usex, lang = lang, sc = sc}&lt;br /&gt;
		&lt;br /&gt;
		local face&lt;br /&gt;
		if quote then&lt;br /&gt;
			face = nil&lt;br /&gt;
		else&lt;br /&gt;
			face = &amp;quot;term&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		usex = require(script_utilities_module).tag_text(usex, lang, sc, face, css_class)&lt;br /&gt;
&lt;br /&gt;
		return usex&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if usex then&lt;br /&gt;
		usex = do_language_and_script_tagging(usex, lang, sc,&lt;br /&gt;
			quote == &amp;quot;quote-meta&amp;quot; and css_classes.quotation_with_citation or&lt;br /&gt;
			quote and css_classes.quotation or css_classes.example)&lt;br /&gt;
		&lt;br /&gt;
		if not nocat then&lt;br /&gt;
			-- Only add [[Citations:foo]] to [[:Category:LANG terms with quotations]] if [[foo]] exists.&lt;br /&gt;
			local ok_to_add_cat&lt;br /&gt;
			if title.nsText ~= &amp;quot;Citations&amp;quot; then&lt;br /&gt;
				ok_to_add_cat = true&lt;br /&gt;
			else&lt;br /&gt;
				-- Here we don&amp;#039;t want to use the subpage text because we check [[Citations:foo]] against [[foo]] and&lt;br /&gt;
				-- if there&amp;#039;s a slash in what follows &amp;#039;Citations:&amp;#039;, we want to check against the full page with the&lt;br /&gt;
				-- slash.&lt;br /&gt;
				local mainspace_title = mw.title.new(title.text)&lt;br /&gt;
				if mainspace_title and mainspace_title.exists then&lt;br /&gt;
					ok_to_add_cat = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if ok_to_add_cat then&lt;br /&gt;
				-- Categories beginning with the language name should use non-etymology-only languages as that&amp;#039;s what the poscat&lt;br /&gt;
				-- system requires, but &amp;#039;Requests for&amp;#039; categories can use etymology-only languages.&lt;br /&gt;
				table.insert(categories, (&amp;quot;%s terms with %ss&amp;quot;):format(termlang:getNonEtymologicalName(), example_type))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if tr then&lt;br /&gt;
			table.insert(categories, (&amp;quot;Requests for native script in %s %ss&amp;quot;):format(quotelang:getCanonicalName(),&lt;br /&gt;
				example_type))&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- TODO: Trigger some kind of error here&lt;br /&gt;
		usex = &amp;quot;&amp;lt;small&amp;gt;(please add the primary text of this &amp;quot; .. example_type .. &amp;quot;)&amp;lt;/small&amp;gt;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if norm then&lt;br /&gt;
		-- Use brackets in HTML entity format just to make sure we don&amp;#039;t interfere with links; add brackets before&lt;br /&gt;
		-- script tagging so that if the script tagging increases the font size, the brackets get increased too.&lt;br /&gt;
		norm = &amp;quot;&amp;amp;#91;&amp;quot; .. norm .. &amp;quot;&amp;amp;#93;&amp;quot;&lt;br /&gt;
		norm = do_language_and_script_tagging(norm, lang, normsc, css_classes.normalization)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local result = {}&lt;br /&gt;
&lt;br /&gt;
	if leftq and #leftq &amp;gt; 0 then&lt;br /&gt;
		table.insert(result, require(&amp;quot;Module:qualifier&amp;quot;).format_qualifier(leftq) .. &amp;quot; &amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(result, usex)&lt;br /&gt;
	if rightq and #rightq &amp;gt; 0 then&lt;br /&gt;
		table.insert(result, &amp;quot; &amp;quot; .. require(&amp;quot;Module:qualifier&amp;quot;).format_qualifier(rightq))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if ref and ref ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		track(&amp;quot;ref&amp;quot;)&lt;br /&gt;
		table.insert(result, ref)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return {&lt;br /&gt;
		usex = table.concat(result),&lt;br /&gt;
		tr = tr,&lt;br /&gt;
		ts = ts,&lt;br /&gt;
		norm = norm&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Format a usex or quotation. Implementation of {{tl|ux}}, {{tl|quote}} and {{tl|quote-*}} templates (e.g.&lt;br /&gt;
{{tl|quote-book}}, {{tl|quote-journal}}, {{tl|quote-web}}, etc.). FIXME: Should also be used by {{tl|Q}} and&lt;br /&gt;
[[Module:Quotations]].&lt;br /&gt;
&lt;br /&gt;
Takes a single object `data`, containining the following fields:&lt;br /&gt;
&lt;br /&gt;
* `usex`: The text of the usex or quotation to format. Semi-mandatory (a maintenance line is displayed if missing).&lt;br /&gt;
* `lang`: The language object of the text. Mandatory. May be an etymology language.&lt;br /&gt;
* `termlang`: The language object of the term, which may be different from the language of the text. Defaults to `lang`.&lt;br /&gt;
              Used for categories. May be an etymology language.&lt;br /&gt;
* `sc`: The script object of the text. Autodetected if not given.&lt;br /&gt;
* `quote`: If specified, this is a quotation rather than a usex (uses a different CSS class that affects formatting).&lt;br /&gt;
* `inline`: If specified, format the usex or quotation inline (on one line).&lt;br /&gt;
* `translation`: Translation of the usex or quotation, if in a foreign language.&lt;br /&gt;
* `lit`: Literal translation (if the translation in `translation` is idiomatic and differs significantly from the&lt;br /&gt;
		 literal translation).&lt;br /&gt;
* `normalization`: Normalized version of the usex or quotation (esp. for older languages where nonstandard spellings&lt;br /&gt;
				   were common).&lt;br /&gt;
* `normsc`: Script object of the normalized text. If unspecified, use the script object given in `sc` if any, otherwise&lt;br /&gt;
            do script detection on the normalized text. If &amp;quot;auto&amp;quot;, do script detection on the normalized text even if&lt;br /&gt;
			a script was specified in `sc`.&lt;br /&gt;
* `transliteration`: Transliteration of the usex. If unspecified, transliterate the normalization if specified and not&lt;br /&gt;
                     in a Latin script and transliterable, otherwise fall back to transliterating the usex text.&lt;br /&gt;
* `transcription`: Transcription of the usex, for languages where the transliteration differs significantly from the&lt;br /&gt;
                   pronunciation.&lt;br /&gt;
* `subst`: String indicating substitutions to perform on the usex/quotation and normalization prior to transliterating&lt;br /&gt;
           them. Multiple substs are comma-separated and individual substs are of the form FROM//TO where FROM is a&lt;br /&gt;
		   Lua pattern and TO is a Lua replacement spec. (FROM/TO is also recognized if no // is present in the&lt;br /&gt;
		   substitution.)&lt;br /&gt;
* `q`: If specified, a list of left qualifiers to display before the usex/quotation text.&lt;br /&gt;
* `qq`: If specified, a list of right qualifiers to display after the usex/quotation text.&lt;br /&gt;
* `qualifiers`: If specified, a list of right qualifiers to display after the usex/quotation text, for compatibility&lt;br /&gt;
                purposes.&lt;br /&gt;
* `ref`: Reference text to display directly after the right qualifiers. (FIXME: Instead, this should be actual&lt;br /&gt;
         references.)&lt;br /&gt;
* `orig`: Original text, if the primary text of the usex or quotation is a translation.&lt;br /&gt;
* `origlang`: The language object of the original text. Mandatory if original text given. May be an etymology language.&lt;br /&gt;
* `origsc`: The script object of the original text. Autodetected if not given.&lt;br /&gt;
* `orignorm`: Normalized version of the original text (esp. for older languages where nonstandard spellings were&lt;br /&gt;
              common).&lt;br /&gt;
* `orignormsc`: Script object of the normalized original text. If unspecified, use the script object given in `origsc`&lt;br /&gt;
                if any, otherwise do script detection on the normalized original text. If &amp;quot;auto&amp;quot;, do script detection&lt;br /&gt;
                on the normalized text even if a script was specified in `origsc`.&lt;br /&gt;
* `origtr`: Transliteration of the original text. If unspecified, transliterate the normalized original text if&lt;br /&gt;
            specified and not in a Latin script and transliterable, otherwise fall back to transliterating the original&lt;br /&gt;
            text.&lt;br /&gt;
* `origts`: Transcription of the original text, for languages where the transliteration differs significantly from the&lt;br /&gt;
            pronunciation.&lt;br /&gt;
* `origsubst`: String indicating substitutions to perform on the original text and normalization thereof prior to&lt;br /&gt;
               transliterating them. Multiple substs are comma-separated and individual substs are of the form FROM//TO&lt;br /&gt;
               where FROM is a Lua pattern and TO is a Lua replacement spec. (FROM/TO is also recognized if no // is&lt;br /&gt;
               present in the substitution.)&lt;br /&gt;
* `origq`: If specified, a list of left qualifiers to display before the original text.&lt;br /&gt;
* `origqq`: If specified, a list of right qualifiers to display after the original text.&lt;br /&gt;
* `origref`: Reference text to display directly after the right qualifiers of the original text. (FIXME: Instead, this&lt;br /&gt;
             should be actual references.)&lt;br /&gt;
* `source`: Source of the quotation, displayed in parens after the quotation text.&lt;br /&gt;
* `footer`: Footer displaying miscellaneous information, shown after the quotation. (Typically this should be in a&lt;br /&gt;
            small font.)&lt;br /&gt;
* `nocat`: Suppress categorization.&lt;br /&gt;
* `sortkey`: Sort key for categories.&lt;br /&gt;
* `brackets`: If specified, show a bracket at the end (used with brackets= in {{tl|quote-*}} templates, which show the&lt;br /&gt;
              bracket at the beginning, to indicate a mention rather than a use).&lt;br /&gt;
* `class`: Additional CSS class surrounding the entire formatted text.&lt;br /&gt;
]==]&lt;br /&gt;
&lt;br /&gt;
function export.format_usex(data)&lt;br /&gt;
	local lang = data.lang&lt;br /&gt;
	local termlang = data.termlang or lang&lt;br /&gt;
	local translation = data.translation&lt;br /&gt;
	local quote = data.quote&lt;br /&gt;
	local lit = data.lit&lt;br /&gt;
	local source = data.source&lt;br /&gt;
	local brackets = data.brackets&lt;br /&gt;
	local footer = data.footer&lt;br /&gt;
	local sortkey = data.sortkey&lt;br /&gt;
&lt;br /&gt;
	local title&lt;br /&gt;
	if data.pagename then -- for testing, doc pages, etc.&lt;br /&gt;
		title = mw.title.new(data.pagename)&lt;br /&gt;
		if not title then&lt;br /&gt;
			error((&amp;quot;Bad value for `data.pagename`: &amp;#039;%s&amp;#039;&amp;quot;):format(data.pagename))&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		title = mw.title.getCurrentTitle()&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	if title.nsText == &amp;quot;Reconstruction&amp;quot; or lang:hasType(&amp;quot;reconstructed&amp;quot;) then&lt;br /&gt;
		error(&amp;quot;Reconstructed languages and reconstructed terms cannot have usage examples, as we have no record of their use.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	]]&lt;br /&gt;
	&lt;br /&gt;
	if lit then&lt;br /&gt;
		lit = &amp;quot;(literally, “&amp;quot; .. span(css_classes.literally, lit) .. &amp;quot;”)&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if source then&lt;br /&gt;
		source = &amp;quot;(&amp;quot; .. span(css_classes.source, source) .. &amp;quot;)&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if footer then&lt;br /&gt;
		footer = span(css_classes.footer, footer)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local example_type = quote and &amp;quot;quotation&amp;quot; or &amp;quot;usage example&amp;quot; -- used in error messages and categories&lt;br /&gt;
	local categories = {}&lt;br /&gt;
&lt;br /&gt;
	local usex_obj = process_usex_text {&lt;br /&gt;
		lang = lang,&lt;br /&gt;
		termlang = termlang,&lt;br /&gt;
		quotelang = lang,&lt;br /&gt;
		usex = data.usex,&lt;br /&gt;
		sc = data.sc,&lt;br /&gt;
		tr = data.transliteration,&lt;br /&gt;
		ts = data.transcription,&lt;br /&gt;
		norm = data.normalization,&lt;br /&gt;
		normsc = data.normsc,&lt;br /&gt;
		subst = data.subst,&lt;br /&gt;
		quote = data.quote,&lt;br /&gt;
		title = title,&lt;br /&gt;
		q = data.q,&lt;br /&gt;
		qq = data.qq,&lt;br /&gt;
		ref = data.ref,&lt;br /&gt;
		nocat = data.nocat,&lt;br /&gt;
		categories = categories,&lt;br /&gt;
		example_type = example_type,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	local orig_obj = data.orig and process_usex_text {&lt;br /&gt;
		lang = data.origlang,&lt;br /&gt;
		-- Any categories derived from the original text should use the language of the main text or the term inside it,&lt;br /&gt;
		-- not the language of the original text.&lt;br /&gt;
		termlang = termlang,&lt;br /&gt;
		quotelang = lang,&lt;br /&gt;
		usex = data.orig,&lt;br /&gt;
		sc = data.origsc,&lt;br /&gt;
		tr = data.origtr,&lt;br /&gt;
		ts = data.origts,&lt;br /&gt;
		norm = data.orignorm,&lt;br /&gt;
		normsc = data.orignormsc,&lt;br /&gt;
		subst = data.origsubst,&lt;br /&gt;
		quote = data.quote,&lt;br /&gt;
		title = title,&lt;br /&gt;
		q = data.origq,&lt;br /&gt;
		qq = data.origqq,&lt;br /&gt;
		ref = data.origref,&lt;br /&gt;
		nocat = data.nocat,&lt;br /&gt;
		categories = categories,&lt;br /&gt;
		example_type = example_type,&lt;br /&gt;
	} or nil&lt;br /&gt;
&lt;br /&gt;
	if translation == &amp;quot;-&amp;quot; then&lt;br /&gt;
		translation = nil&lt;br /&gt;
		table.insert(categories, (&amp;quot;%s %ss with omitted translation&amp;quot;):format(lang:getNonEtymologicalName(),&lt;br /&gt;
			example_type))&lt;br /&gt;
	elseif translation then&lt;br /&gt;
		translation = span(css_classes.translation, translation)&lt;br /&gt;
	else&lt;br /&gt;
		local langcode = lang:getNonEtymologicalCode()&lt;br /&gt;
		local origlangcode = data.origlang and data.origlang:getNonEtymologicalCode()&lt;br /&gt;
		if langcode ~= &amp;quot;en&amp;quot; and langcode ~= &amp;quot;mul&amp;quot; and langcode ~= &amp;quot;und&amp;quot; and origlangcode ~= &amp;quot;en&amp;quot; then&lt;br /&gt;
			-- add trreq category if translation is unspecified and language is not english, translingual or&lt;br /&gt;
			-- undetermined&lt;br /&gt;
			table.insert(categories, (&amp;quot;Requests for translations of %s %ss&amp;quot;):format(lang:getCanonicalName(),&lt;br /&gt;
				example_type))&lt;br /&gt;
			if quote then&lt;br /&gt;
				translation = &amp;quot;&amp;lt;small&amp;gt;(please [[WT:Quotations#Adding translations to quotations|add an English translation]] of this &amp;quot;&lt;br /&gt;
					.. example_type .. &amp;quot;)&amp;lt;/small&amp;gt;&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				translation = &amp;quot;&amp;lt;small&amp;gt;(please add an English translation of this &amp;quot; .. example_type .. &amp;quot;)&amp;lt;/small&amp;gt;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local result = {}&lt;br /&gt;
	local function ins(text)&lt;br /&gt;
		table.insert(result, text)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	ins(usex_obj.usex)&lt;br /&gt;
&lt;br /&gt;
	if data.inline then&lt;br /&gt;
		local function insert_annotations(obj)&lt;br /&gt;
			if obj.norm then&lt;br /&gt;
				ins(&amp;quot; &amp;quot; .. obj.norm)&lt;br /&gt;
			end&lt;br /&gt;
			if obj.tr or obj.ts then&lt;br /&gt;
				ins(&amp;quot; ―&amp;quot;)&lt;br /&gt;
				if obj.tr then&lt;br /&gt;
					ins(&amp;quot; &amp;quot; .. obj.tr)&lt;br /&gt;
				end&lt;br /&gt;
				if obj.ts then&lt;br /&gt;
					ins(&amp;quot; &amp;quot; .. obj.ts)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		insert_annotations(usex_obj)&lt;br /&gt;
&lt;br /&gt;
		if orig_obj then&lt;br /&gt;
			ins(&amp;quot; (&amp;quot;)&lt;br /&gt;
			ins(&amp;quot;[&amp;quot; .. original_text .. orig_obj.usex .. &amp;quot;]&amp;quot;)&lt;br /&gt;
			insert_annotations(orig_obj)&lt;br /&gt;
			ins(&amp;quot;)&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if translation then&lt;br /&gt;
			ins(&amp;quot; ― &amp;quot; .. translation)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if lit then&lt;br /&gt;
			ins(&amp;quot; &amp;quot; .. lit)&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if source then&lt;br /&gt;
			ins(&amp;quot; &amp;quot; .. source)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if footer then&lt;br /&gt;
			ins(&amp;quot; &amp;quot; .. footer)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if data.brackets then&lt;br /&gt;
			ins(&amp;quot;]&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		result = table.concat(result)&lt;br /&gt;
	else&lt;br /&gt;
		local any_usex_annotations = usex_obj.tr or usex_obj.ts or usex_obj.norm or translation or lit&lt;br /&gt;
		local any_orig_annotations = orig_obj and (orig_obj.tr or orig_obj.ts or orig_obj.norm)&lt;br /&gt;
		if any_usex_annotations or orig_obj or source or footer then&lt;br /&gt;
			ins(&amp;quot;&amp;lt;dl&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
			local function insert_dd(text)&lt;br /&gt;
				if text then&lt;br /&gt;
					ins(&amp;quot;&amp;lt;dd&amp;gt;&amp;quot;)&lt;br /&gt;
					ins(text)&lt;br /&gt;
					if data.brackets then&lt;br /&gt;
						ins(BRACKET_SUB)&lt;br /&gt;
					end&lt;br /&gt;
					ins(&amp;quot;&amp;lt;/dd&amp;gt;&amp;quot;)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			insert_dd(usex_obj.norm)&lt;br /&gt;
			insert_dd(usex_obj.tr)&lt;br /&gt;
			insert_dd(usex_obj.ts)&lt;br /&gt;
&lt;br /&gt;
			if orig_obj then&lt;br /&gt;
				insert_dd(&amp;quot;[&amp;quot; .. original_text .. orig_obj.usex .. &amp;quot;]&amp;quot;)&lt;br /&gt;
				if any_orig_annotations then&lt;br /&gt;
					ins(&amp;quot;&amp;lt;dd&amp;gt;&amp;lt;dl&amp;gt;&amp;quot;)&lt;br /&gt;
					insert_dd(orig_obj.norm)&lt;br /&gt;
					insert_dd(orig_obj.tr)&lt;br /&gt;
					insert_dd(orig_obj.ts)&lt;br /&gt;
					ins(&amp;quot;&amp;lt;/dl&amp;gt;&amp;lt;/dd&amp;gt;&amp;quot;)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			insert_dd(translation)&lt;br /&gt;
			insert_dd(lit)&lt;br /&gt;
&lt;br /&gt;
			if source or footer then&lt;br /&gt;
				if any_usex_annotations then&lt;br /&gt;
					ins(&amp;quot;&amp;lt;dd&amp;gt;&amp;lt;dl&amp;gt;&amp;quot;)&lt;br /&gt;
				end&lt;br /&gt;
				insert_dd(source)&lt;br /&gt;
				insert_dd(footer)&lt;br /&gt;
				if any_usex_annotations then&lt;br /&gt;
					ins(&amp;quot;&amp;lt;/dl&amp;gt;&amp;lt;/dd&amp;gt;&amp;quot;)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			ins(&amp;quot;&amp;lt;/dl&amp;gt;&amp;quot;)&lt;br /&gt;
		elseif data.brackets then&lt;br /&gt;
			ins(BRACKET_SUB)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		result = table.concat(result)&lt;br /&gt;
		if data.brackets then&lt;br /&gt;
			result = result:gsub(&amp;quot;^(.*)&amp;quot; .. BRACKET_SUB, &amp;quot;%1]&amp;quot;):gsub(BRACKET_SUB, &amp;quot;&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local class = quote and css_classes.container_quotation or css_classes.container_ux&lt;br /&gt;
	if data.class then&lt;br /&gt;
		class = class .. &amp;quot; &amp;quot; .. data.class&lt;br /&gt;
	end&lt;br /&gt;
	result = (data.inline and span or div)(class, result)&lt;br /&gt;
	return result .. require(&amp;quot;Module:utilities&amp;quot;).format_categories(categories, lang, sortkey)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>imported&gt;Vaxjedi</name></author>
	</entry>
</feed>