<?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%3ACite_LSA</id>
	<title>Module:Cite LSA - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_LSA"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Cite_LSA&amp;action=history"/>
	<updated>2026-05-24T08:10:57Z</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:Cite_LSA&amp;diff=135631&amp;oldid=prev</id>
		<title>imported&gt;Trappist the monk: sync from sandbox;</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Cite_LSA&amp;diff=135631&amp;oldid=prev"/>
		<updated>2022-11-13T15:25:55Z</updated>

		<summary type="html">&lt;p&gt;sync from sandbox;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
--[[--------------------------&amp;lt; M A K E _ C I T E R E F _ I D &amp;gt;------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns nil.&lt;br /&gt;
&lt;br /&gt;
namelist_t is one of the authorlast{} (|last1= ... |lastn=) or editorlast{} (|editorlast1= ... |editorlastn=) sequence&lt;br /&gt;
tables chosen in that order.  year is the value from |year=&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function make_citeref_id (namelist_t, year)&lt;br /&gt;
	local names_t={};															-- a sequence table for the one to four names and year&lt;br /&gt;
	for i,v in ipairs (namelist_t) do											-- loop through the list and take up to the first four last names&lt;br /&gt;
		names_t[i] = v;&lt;br /&gt;
		if i == 4 then break end												-- if four then done&lt;br /&gt;
	end&lt;br /&gt;
	table.insert (names_t, year);												-- add the year at the end; may be the only entry&lt;br /&gt;
	local id = table.concat(names_t);											-- concatenate names_t and year for CITEREF id&lt;br /&gt;
	if &amp;#039;&amp;#039; ~= id then															-- if concatenation is not an empty string&lt;br /&gt;
		return &amp;quot;CITEREF&amp;quot; .. id;													-- add the CITEREF prefix&lt;br /&gt;
	else&lt;br /&gt;
		return;																	-- return nil; no reason to include CITEREF id in this citation&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P . C I T E &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
implements Template:Cite LSA&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
function p.cite(frame)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	local authorfirst = {}&lt;br /&gt;
	local authorlast = {}&lt;br /&gt;
	local editorfirst = {}&lt;br /&gt;
	local editorlast = {}&lt;br /&gt;
&lt;br /&gt;
	for k,v in pairs(args) do&lt;br /&gt;
		local num, i, j;&lt;br /&gt;
&lt;br /&gt;
		if string.find(k, &amp;quot;first&amp;quot;) ~= nil then&lt;br /&gt;
			if string.find(k, &amp;quot;%d&amp;quot;) ~= nil then&lt;br /&gt;
				i,j = string.find(k, &amp;quot;%d&amp;quot;)&lt;br /&gt;
				num = string.sub(k,i,j)&lt;br /&gt;
				num = tonumber(num)&lt;br /&gt;
			else&lt;br /&gt;
				num = 1&lt;br /&gt;
			end&lt;br /&gt;
			if string.find(k, &amp;quot;editor&amp;quot;) ~= nil then&lt;br /&gt;
				editorfirst[num] = v&lt;br /&gt;
			else&lt;br /&gt;
				authorfirst[num] = v&lt;br /&gt;
			end&lt;br /&gt;
		elseif string.find(k, &amp;quot;last&amp;quot;) ~= nil then&lt;br /&gt;
			if string.find(k, &amp;quot;%d&amp;quot;) ~= nil then&lt;br /&gt;
				i,j = string.find(k, &amp;quot;%d&amp;quot;)&lt;br /&gt;
				num = string.sub(k,i,j)&lt;br /&gt;
				num = tonumber(num)&lt;br /&gt;
			else&lt;br /&gt;
				num = 1&lt;br /&gt;
			end&lt;br /&gt;
			if string.find(k, &amp;quot;editor&amp;quot;) ~= nil then&lt;br /&gt;
				editorlast[num] = v&lt;br /&gt;
			else&lt;br /&gt;
				authorlast[num] = v&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local publisher = args.publisher&lt;br /&gt;
	local author = args.last													-- required&lt;br /&gt;
	local authorlist;&lt;br /&gt;
	&lt;br /&gt;
	if table.getn(authorlast) &amp;lt; 1 and publisher ~= nil then&lt;br /&gt;
		authorlist=publisher .. &amp;quot;. &amp;quot;&lt;br /&gt;
		author=&amp;quot;&amp;quot;&lt;br /&gt;
	elseif table.getn(authorlast) &amp;gt; 0 then&lt;br /&gt;
		local alimit = table.getn(authorlast)&lt;br /&gt;
		for i,v in ipairs(authorlast) do&lt;br /&gt;
			if i == 1 then&lt;br /&gt;
				authorlist = authorlast[1] .. &amp;quot;, &amp;quot; .. authorfirst[1];&lt;br /&gt;
			elseif i &amp;gt; 1 and i &amp;lt;= alimit then&lt;br /&gt;
				authorlist = authorlist .. authorfirst[i] .. &amp;quot; &amp;quot; .. authorlast[i];&lt;br /&gt;
			end&lt;br /&gt;
			if i+1 == alimit then&lt;br /&gt;
				authorlist = authorlist .. &amp;quot;, and &amp;quot;&lt;br /&gt;
			elseif alimit == 1 then&lt;br /&gt;
				authorlist = authorlist .. &amp;quot;. &amp;quot;&lt;br /&gt;
			elseif alimit &amp;gt; 2 and i ~= alimit then&lt;br /&gt;
				authorlist = authorlist .. &amp;quot;; &amp;quot;&lt;br /&gt;
			elseif i == alimit then&lt;br /&gt;
				authorlist = authorlist .. &amp;quot;. &amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local editorlist = nil&lt;br /&gt;
	if editorlast ~= {} then&lt;br /&gt;
		editorlist = &amp;quot;&amp;quot;&lt;br /&gt;
		local elimit = table.getn(editorlast)&lt;br /&gt;
		for i,v in ipairs(editorlast) do&lt;br /&gt;
			editorlist = editorlist .. editorfirst[i] .. &amp;quot; &amp;quot; .. editorlast[i]&lt;br /&gt;
			if i+1 == elimit and editorlist ~= &amp;quot; &amp;quot; then&lt;br /&gt;
				editorlist = editorlist .. &amp;quot;, and &amp;quot;&lt;br /&gt;
			elseif elimit &amp;gt; i and editorlist ~= &amp;quot; &amp;quot; then&lt;br /&gt;
				editorlist = editorlist .. &amp;quot;, &amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if editorlist == &amp;quot;&amp;quot; or editorlist == &amp;quot; &amp;quot; then&lt;br /&gt;
			editorlist = &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local year = args.year														-- required&lt;br /&gt;
	if author and year then&lt;br /&gt;
		authorlist = authorlist .. year .. &amp;quot;. &amp;quot;&lt;br /&gt;
	elseif author then&lt;br /&gt;
		authorlist = authorlist .. &amp;quot; &amp;lt;span class=\&amp;quot;cslsa-error\&amp;quot;&amp;gt;Missing year&amp;lt;/span&amp;gt;&amp;quot; .. &amp;quot;. &amp;quot;&lt;br /&gt;
	elseif year then&lt;br /&gt;
		authorlist = &amp;quot;&amp;lt;span class=\&amp;quot;cslsa-error\&amp;quot;&amp;gt;Missing author name&amp;lt;/span&amp;gt;&amp;quot; .. year .. &amp;quot;. &amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		authorlist = &amp;quot;&amp;lt;span class=\&amp;quot;cslsa-error\&amp;quot;&amp;gt;Missing author name; missing year&amp;lt;/span&amp;gt;&amp;quot; .. &amp;quot;. &amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local title = (args.title and args.title) or &amp;quot;&amp;lt;span class=\&amp;quot;cslsa-error\&amp;quot;&amp;gt;Missing title&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
	local journal = args.journal&lt;br /&gt;
	local chapter = args.chapter&lt;br /&gt;
	local series = args.seriestitle or args.series&lt;br /&gt;
	local volume = args.volume&lt;br /&gt;
	local issue = (args.issue and &amp;#039;(&amp;#039; .. args.issue .. &amp;#039;)&amp;#039;) or &amp;#039;&amp;#039;;				-- journal cites only&lt;br /&gt;
	local edition = args.edition&lt;br /&gt;
	local pages = (args.pages and args.pages .. &amp;quot;.&amp;quot;) or &amp;#039;&amp;#039;;&lt;br /&gt;
	local url = args.url&lt;br /&gt;
	local doi = args.doi&lt;br /&gt;
	if doi ~= nil then&lt;br /&gt;
		url=&amp;#039;https://doi.org/&amp;#039;..doi&lt;br /&gt;
	end&lt;br /&gt;
	local accessdate = (args.accessdate and &amp;quot; Accessed &amp;quot; .. args.accessdate .. &amp;quot;.&amp;quot;) or &amp;#039;&amp;#039;;&lt;br /&gt;
	local place = args.place&lt;br /&gt;
	local citation = nil&lt;br /&gt;
	if journal ~= nil then&lt;br /&gt;
		journal = &amp;quot;\&amp;#039;\&amp;#039;&amp;quot; .. journal .. &amp;quot;\&amp;#039;\&amp;#039;&amp;quot;;									-- italicize journal&lt;br /&gt;
		volume = (volume and volume or &amp;#039;&amp;#039;) .. issue;							-- composit volume and issue&lt;br /&gt;
		if &amp;#039;&amp;#039; ~= volume then&lt;br /&gt;
			journal = journal .. &amp;quot; &amp;quot; .. volume;&lt;br /&gt;
		end&lt;br /&gt;
		if url then&lt;br /&gt;
			title = &amp;quot;[&amp;quot; .. url .. &amp;quot; &amp;quot; .. title .. &amp;quot;]. &amp;quot;;							-- link title with url&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		citation = authorlist .. title .. journal .. &amp;quot;. &amp;quot; .. pages .. accessdate;&lt;br /&gt;
&lt;br /&gt;
	elseif journal == nil then&lt;br /&gt;
		if chapter ~= nil then&lt;br /&gt;
			if url ~= nil then&lt;br /&gt;
				citation = authorlist .. &amp;quot;[&amp;quot; .. url .. &amp;quot; &amp;quot; .. chapter .. &amp;quot;].&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				citation = authorlist .. chapter .. &amp;quot;. &amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
			if title ~= nil then&lt;br /&gt;
				citation = citation .. &amp;quot;\&amp;#039;\&amp;#039;&amp;quot; .. title .. &amp;quot;\&amp;#039;\&amp;#039;&amp;quot;&lt;br /&gt;
				if editorlist ~= nil and editorlist ~= &amp;quot;&amp;quot; then&lt;br /&gt;
					citation = citation .. &amp;quot; ed. by &amp;quot; .. editorlist&lt;br /&gt;
				end&lt;br /&gt;
				if &amp;#039;&amp;#039; ~= pages then&lt;br /&gt;
					citation = citation .. &amp;quot;, &amp;quot; .. pages;&lt;br /&gt;
				else&lt;br /&gt;
					citation = citation .. &amp;quot;. &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if edition ~= nil and volume ~= nil then&lt;br /&gt;
					citation = citation .. edition .. &amp;quot;, &amp;quot; .. volume .. &amp;quot;; &amp;quot; &lt;br /&gt;
				elseif edition ~= nil and volume == nil then&lt;br /&gt;
					citation = citation .. edition .. &amp;quot;; &amp;quot;&lt;br /&gt;
				elseif edition == nil and volume ~= nil then&lt;br /&gt;
					citation = citation .. volume .. &amp;quot;; &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if series ~= nil then&lt;br /&gt;
					citation = citation .. &amp;quot;(&amp;quot; .. series .. &amp;quot;). &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if place ~= nil and publisher ~= nil then&lt;br /&gt;
					citation = citation .. place .. &amp;quot;: &amp;quot; .. publisher .. &amp;quot;.&amp;quot;&lt;br /&gt;
				elseif place ~= nil and publisher == nil then&lt;br /&gt;
					citation = citation .. place .. &amp;quot;.&amp;quot;&lt;br /&gt;
				elseif place == nil and publisher ~= nil then&lt;br /&gt;
					citation = citation .. publisher .. &amp;quot;.&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if url ~= nil then&lt;br /&gt;
					citation = citation .. accessdate .. &amp;quot;. &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if title ~= nil then&lt;br /&gt;
				if url ~= nil then&lt;br /&gt;
					citation = authorlist .. &amp;quot;\&amp;#039;\&amp;#039;[&amp;quot; .. url .. &amp;quot; &amp;quot; .. title .. &amp;quot;]\&amp;#039;\&amp;#039;&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					citation = authorlist .. &amp;quot;\&amp;#039;\&amp;#039;&amp;quot; .. title .. &amp;quot;\&amp;#039;\&amp;#039;&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if editorlist ~= nil and editorlist ~= &amp;quot;&amp;quot; then&lt;br /&gt;
					citation = citation .. &amp;quot;, ed. by &amp;quot; .. editorlist&lt;br /&gt;
				end&lt;br /&gt;
				if &amp;#039;&amp;#039; ~= pages then&lt;br /&gt;
					citation = citation .. &amp;quot;, &amp;quot; .. pages;&lt;br /&gt;
				else&lt;br /&gt;
					citation = citation .. &amp;quot;. &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if edition ~= nil and volume ~= nil then&lt;br /&gt;
					citation = citation .. edition .. &amp;quot;, &amp;quot; .. volume .. &amp;quot;; &amp;quot; &lt;br /&gt;
				elseif edition ~= nil and volume == nil then&lt;br /&gt;
					citation = citation .. edition .. &amp;quot;; &amp;quot;&lt;br /&gt;
				elseif edition == nil and volume ~= nil then&lt;br /&gt;
					citation = citation .. volume .. &amp;quot;; &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if series ~= nil then&lt;br /&gt;
					citation = citation .. &amp;quot;(&amp;quot; .. series .. &amp;quot;). &amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if place ~= nil and publisher ~= nil then&lt;br /&gt;
					citation = citation .. place .. &amp;quot;: &amp;quot; .. publisher .. &amp;quot;.&amp;quot;&lt;br /&gt;
				elseif place ~= nil and publisher == nil then&lt;br /&gt;
					citation = citation .. place .. &amp;quot;.&amp;quot;&lt;br /&gt;
				elseif place == nil and publisher ~= nil then&lt;br /&gt;
					citation = citation .. publisher .. &amp;quot;.&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				if url ~= nil then&lt;br /&gt;
					citation = citation .. accessdate .. &amp;quot;.&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local namelist_t = {};														-- holds selected authorlast or editorlast name list	&lt;br /&gt;
	if #authorlast &amp;gt; 0 then														-- is there an author list?&lt;br /&gt;
		namelist_t = authorlast;												-- use the author list&lt;br /&gt;
	elseif #editorlast &amp;gt; 0 then													-- if not, is there an editor list?&lt;br /&gt;
		namelist_t = editorlast;												-- use the editor list&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local citeref_id;&lt;br /&gt;
	if #namelist_t &amp;gt; 0 then														-- if there are names in namelist_t&lt;br /&gt;
		citeref_id = make_citeref_id (namelist_t, year);						-- go make the CITEREF anchor&lt;br /&gt;
		citeref_id = mw.uri.anchorEncode (citeref_id);							-- and anchor encode it&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat ({&lt;br /&gt;
		frame:extensionTag ({name=&amp;#039;templatestyles&amp;#039;, args={src=&amp;#039;Module:Cite LSA/styles.css&amp;#039;}}),	-- add templates styles&lt;br /&gt;
		&amp;#039;&amp;lt;cite class=&amp;quot;citation cslsa&amp;quot;&amp;#039;,											-- open the cite tag with class attribute&lt;br /&gt;
		citeref_id and (&amp;#039;id=&amp;quot;&amp;#039; .. citeref_id .. &amp;#039;&amp;quot;&amp;gt;&amp;#039;) or &amp;#039;&amp;quot;&amp;gt;&amp;#039;;					-- add id attribute and close the tag; or simply close when no id&lt;br /&gt;
		citation,																-- add the citation&lt;br /&gt;
		&amp;#039;&amp;lt;/cite&amp;gt;&amp;#039;																-- add the terminal cite tag&lt;br /&gt;
		});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Trappist the monk</name></author>
	</entry>
</feed>