<?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%3Acode</id>
	<title>Module:code - 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%3Acode"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:code&amp;action=history"/>
	<updated>2026-04-17T13:10:28Z</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:code&amp;diff=494178&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local decode_entities = require(&quot;Module:string utilities&quot;).decode_entities local gsub = string.gsub local insert = table.insert local match = string.match local process_params = require(&quot;Module:parameters&quot;).process local tonumber = tonumber local unstripNoWiki = mw.text.unstripNoWiki local yesno = require(&quot;Module:yesno&quot;)  local export = {}  local function get_args(frame) 	local params = { 		[1] = {required = true, default = &quot;code&quot;}, 		[&quot;&quot;] = {alias_of = 1}, 		[&quot;line&quot;] =...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:code&amp;diff=494178&amp;oldid=prev"/>
		<updated>2026-04-16T15:47:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local decode_entities = require(&amp;quot;Module:string utilities&amp;quot;).decode_entities local gsub = string.gsub local insert = table.insert local match = string.match local process_params = require(&amp;quot;Module:parameters&amp;quot;).process local tonumber = tonumber local unstripNoWiki = mw.text.unstripNoWiki local yesno = require(&amp;quot;Module:yesno&amp;quot;)  local export = {}  local function get_args(frame) 	local params = { 		[1] = {required = true, default = &amp;quot;code&amp;quot;}, 		[&amp;quot;&amp;quot;] = {alias_of = 1}, 		[&amp;quot;line&amp;quot;] =...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local decode_entities = require(&amp;quot;Module:string utilities&amp;quot;).decode_entities&lt;br /&gt;
local gsub = string.gsub&lt;br /&gt;
local insert = table.insert&lt;br /&gt;
local match = string.match&lt;br /&gt;
local process_params = require(&amp;quot;Module:parameters&amp;quot;).process&lt;br /&gt;
local tonumber = tonumber&lt;br /&gt;
local unstripNoWiki = mw.text.unstripNoWiki&lt;br /&gt;
local yesno = require(&amp;quot;Module:yesno&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local export = {}&lt;br /&gt;
&lt;br /&gt;
local function get_args(frame)&lt;br /&gt;
	local params = {&lt;br /&gt;
		[1] = {required = true, default = &amp;quot;code&amp;quot;},&lt;br /&gt;
		[&amp;quot;&amp;quot;] = {alias_of = 1},&lt;br /&gt;
		[&amp;quot;line&amp;quot;] = true,&lt;br /&gt;
		[&amp;quot;highlight&amp;quot;] = true,&lt;br /&gt;
		[&amp;quot;inline&amp;quot;] = {type = &amp;quot;boolean&amp;quot;},&lt;br /&gt;
		[&amp;quot;class&amp;quot;] = true,&lt;br /&gt;
		[&amp;quot;style&amp;quot;] = true,&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local lang = process_params(frame.args, {&lt;br /&gt;
		[&amp;quot;lang&amp;quot;] = true&lt;br /&gt;
	}).lang&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	&lt;br /&gt;
	-- Specialised language templates (e.g. {{lua}}).&lt;br /&gt;
	if lang then&lt;br /&gt;
		args = process_params(args, params)&lt;br /&gt;
		return args, lang, args[1]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	params[&amp;quot;lang&amp;quot;] = {default = &amp;quot;text&amp;quot;}&lt;br /&gt;
	&lt;br /&gt;
	-- If 2= or &amp;quot;=...&amp;quot; are given, treat 1= as an alias of lang=.&lt;br /&gt;
	if args[2] or args[&amp;quot;&amp;quot;] then&lt;br /&gt;
		insert(params, 1, {alias_of = &amp;quot;lang&amp;quot;})&lt;br /&gt;
		params[&amp;quot;&amp;quot;].alias_of = 2&lt;br /&gt;
		args = process_params(args, params)&lt;br /&gt;
		return args, args.lang, args[2]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Otherwise, 1= is just the input text.&lt;br /&gt;
	args = process_params(args, params)&lt;br /&gt;
	return args, args.lang, args[1]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.show(frame)&lt;br /&gt;
	local args, lang, text = get_args(frame)&lt;br /&gt;
	&lt;br /&gt;
	lang = lang == &amp;quot;js&amp;quot; and &amp;quot;javascript&amp;quot; or lang == &amp;quot;py&amp;quot; and &amp;quot;python&amp;quot; or lang&lt;br /&gt;
	&lt;br /&gt;
	local inline, line, start, highlight = args.inline&lt;br /&gt;
	if not inline then&lt;br /&gt;
		-- If `line` is a boolean, start at line 1; otherwise, if it&amp;#039;s a number,&lt;br /&gt;
		-- start at that line.&lt;br /&gt;
		line = args.line&lt;br /&gt;
		if line then&lt;br /&gt;
			start = match(line, &amp;quot;^%d+$&amp;quot;)&lt;br /&gt;
			if start == nil then&lt;br /&gt;
				line = yesno(line) or nil&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		-- Offset `highlight` based on `start`.&lt;br /&gt;
		highlight = args.highlight&lt;br /&gt;
		if highlight and start then&lt;br /&gt;
			local offset = tonumber(start) - 1&lt;br /&gt;
			highlight = gsub(highlight, &amp;quot;%d+&amp;quot;, function(n)&lt;br /&gt;
				return tonumber(n) - offset&lt;br /&gt;
			end)&lt;br /&gt;
		end&lt;br /&gt;
		-- If `inline` isn&amp;#039;t specified, default to false if `line` or&lt;br /&gt;
		-- `highlight` are given; otherwise, default to true.&lt;br /&gt;
		inline = inline == nil and not (line or highlight) or nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Unstrip nowiki tags and decode any HTML entities, because&lt;br /&gt;
	-- syntaxhighlight won&amp;#039;t decode them on display.&lt;br /&gt;
	return frame:extensionTag(&lt;br /&gt;
		&amp;quot;syntaxhighlight&amp;quot;,&lt;br /&gt;
		decode_entities(unstripNoWiki(text)), {&lt;br /&gt;
		lang = lang,&lt;br /&gt;
		line = line,&lt;br /&gt;
		start = start,&lt;br /&gt;
		highlight = highlight,&lt;br /&gt;
		inline = inline,&lt;br /&gt;
		class = args.class,&lt;br /&gt;
		style = args.style or inline and &amp;quot;white-space:pre-wrap;&amp;quot; or nil&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>