<?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%3ASandbox%2Ftrappist_the_monk%2Fmath</id>
	<title>Module:Sandbox/trappist the monk/math - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Ftrappist_the_monk%2Fmath"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/trappist_the_monk/math&amp;action=history"/>
	<updated>2026-05-27T20:20:49Z</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:Sandbox/trappist_the_monk/math&amp;diff=146619&amp;oldid=prev</id>
		<title>imported&gt;Legoktm: Replace Module:No globals with require( &quot;strict&quot; )</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/trappist_the_monk/math&amp;diff=146619&amp;oldid=prev"/>
		<updated>2022-10-23T21:04:26Z</updated>

		<summary type="html">&lt;p&gt;Replace &lt;a href=&quot;/research/Module:No_globals&quot; title=&quot;Module:No globals&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;require(&amp;#039;strict&amp;#039;);&lt;br /&gt;
-- &amp;lt;math display=inline&amp;gt;3987^{12} + 4365^{12} = 4472^{12}&amp;lt;/math&amp;gt;&lt;br /&gt;
local function math_test (frame)&lt;br /&gt;
	local math_title = frame.args[&amp;#039;math-title&amp;#039;];&lt;br /&gt;
	if math_title:find (&amp;#039;\127[^\127]*UNIQ%-%-math%-[%a%d]+%-QINU[^\127]*\127&amp;#039;) then&lt;br /&gt;
		return &amp;#039;&amp;lt;span style=&amp;quot;color:#d33&amp;quot;&amp;gt;math-title has &amp;lt;math&amp;gt;...&amp;lt;/math&amp;gt; markup&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local math_t = {};															-- temporary holding spot for math strip markers&lt;br /&gt;
	local escaped = &amp;#039;__35c4p3d__&amp;#039;;												-- the special secret EScApEd keyword&lt;br /&gt;
	local str = math_title:gsub (&amp;#039;\\%$&amp;#039;, escaped);								-- replace &amp;#039;\$&amp;#039; (escaped $) with special secret EScApEd keyword&lt;br /&gt;
&lt;br /&gt;
	local count;&lt;br /&gt;
	str, count = str:gsub (&amp;#039;%$&amp;#039;, &amp;#039;%1&amp;#039;);											-- there must be $-delimited text and the delimters must be balanced&lt;br /&gt;
	if 0 == count then&lt;br /&gt;
		return &amp;#039;&amp;lt;span style=&amp;quot;color:#d33&amp;quot;&amp;gt;|math-title= missing TeX delimiters&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;
	elseif 0 ~= count % 2 then&lt;br /&gt;
		return &amp;#039;&amp;lt;span style=&amp;quot;color:#d33&amp;quot;&amp;gt;|math-title= has unbalanced TeX delimiters&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local pattern = &amp;#039;(%$([^%$]+)%$)&amp;#039;;											-- pattern used to find $-delimited math text&lt;br /&gt;
	for math_str in str:gmatch (pattern) do										-- walk through the text and for each $-delimited math text&lt;br /&gt;
		math_str = math_str:gsub (pattern, &amp;#039;&amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;%2&amp;lt;/math&amp;gt;&amp;#039;);	-- replace the delimiters&lt;br /&gt;
		math_str = math_str:gsub (escaped, &amp;#039;\\%$&amp;#039;);								-- replace special secret EScApEd keyword with &amp;#039;\$&amp;#039;&lt;br /&gt;
		math_str = frame:preprocess (math_str);									-- preprocess math text into a math strip marker&lt;br /&gt;
		table.insert (math_t, math_str);										-- and save the math strip marker&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _, stripmarker in ipairs (math_t) do&lt;br /&gt;
		str = str:gsub (pattern, stripmarker, 1);								-- replace $-delimited math text with matching strip marker&lt;br /&gt;
	end&lt;br /&gt;
	str = str:gsub (escaped, &amp;#039;%$&amp;#039;);												-- replace special secret EScApEd keyword with unescaped form &amp;#039;$&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	return table.concat ({&lt;br /&gt;
		&amp;#039;math title: &amp;#039;,&lt;br /&gt;
		str,&lt;br /&gt;
		&amp;#039;; metadata: &amp;lt;code&amp;gt;&amp;#039;,&lt;br /&gt;
		math_title,&lt;br /&gt;
		&amp;#039;&amp;lt;/code&amp;gt;&amp;#039;&lt;br /&gt;
		});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function math_test2 (frame)&lt;br /&gt;
	local math_title = frame.args[&amp;#039;math-title&amp;#039;];&lt;br /&gt;
	if math_title:find (&amp;#039;\127[^\127]*UNIQ%-%-math%-[%a%d]+%-QINU[^\127]*\127&amp;#039;) then&lt;br /&gt;
		return &amp;#039;&amp;lt;span style=&amp;quot;color:#d33&amp;quot;&amp;gt;math-title has &amp;lt;math&amp;gt;...&amp;lt;/math&amp;gt; markup&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local math_t = {};															-- temporary holding spot for math strip markers&lt;br /&gt;
	local str = math_title;&lt;br /&gt;
	local pattern = &amp;#039;(\\%((.-)\\%))&amp;#039;;											-- pattern used to find \(...\) delimited math text&lt;br /&gt;
&lt;br /&gt;
	if not str:find (pattern) then												-- there must be \(...\) delimited text and the delimters must be balanced&lt;br /&gt;
		return &amp;#039;&amp;lt;span style=&amp;quot;color:#d33&amp;quot;&amp;gt;|math-title= missing TeX delimiters&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for math_str in str:gmatch (pattern) do										-- walk through the text and for each \(...\) delimited math text&lt;br /&gt;
		math_str = math_str:gsub (pattern, &amp;#039;&amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;%2&amp;lt;/math&amp;gt;&amp;#039;);	-- replace the delimiters&lt;br /&gt;
		math_str = frame:preprocess (math_str);									-- preprocess math text into a math strip marker&lt;br /&gt;
		table.insert (math_t, math_str);										-- and save the math strip marker&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _, stripmarker in ipairs (math_t) do&lt;br /&gt;
		str = str:gsub (pattern, stripmarker, 1);								-- replace \(...\) delimited math text with matching strip marker&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat ({&lt;br /&gt;
		&amp;#039;math title: &amp;#039;,&lt;br /&gt;
		str,&lt;br /&gt;
		&amp;#039;; metadata: &amp;lt;code&amp;gt;&amp;#039;,&lt;br /&gt;
		math_title,&lt;br /&gt;
		&amp;#039;&amp;lt;/code&amp;gt;&amp;#039;&lt;br /&gt;
		});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function span_test (frame)&lt;br /&gt;
	local span_str = frame.args[1];&lt;br /&gt;
	&lt;br /&gt;
	local patterns_t = {&lt;br /&gt;
		{&amp;#039;\127[^\127]*UNIQ%-%-(%a+)%-[%a%d]+%-QINU[^\127]*\127&amp;#039;, &amp;#039;&amp;#039;},			-- remove any stripmarkers&lt;br /&gt;
		{&amp;#039;&amp;lt;br */*&amp;gt;&amp;#039;, &amp;#039;&amp;#039;},														-- remove any &amp;lt;br /&amp;gt; html tags ({{chem2}})&lt;br /&gt;
		{&amp;#039;(&amp;lt;span [^&amp;gt;]*)class *= *&amp;quot;[^&amp;quot;]*&amp;quot;([^&amp;gt;]*&amp;gt;)&amp;#039;, &amp;#039;%1%2&amp;#039;},						-- remove class attributes from &amp;lt;span ...&amp;gt; tags&lt;br /&gt;
		{&amp;#039;(&amp;lt;span [^&amp;gt;]*)style *= *&amp;quot;[^&amp;quot;]*&amp;quot;([^&amp;gt;]*&amp;gt;)&amp;#039;, &amp;#039;%1%2&amp;#039;},						-- remove style attributes from &amp;lt;span ...&amp;gt; tags&lt;br /&gt;
		{&amp;#039;(&amp;lt;span [^&amp;gt;]*)title *= *&amp;quot;[^&amp;quot;]*&amp;quot;([^&amp;gt;]*&amp;gt;)&amp;#039;, &amp;#039;%1%2&amp;#039;},						-- remove title attributes from &amp;lt;span ...&amp;gt; tags&lt;br /&gt;
		{&amp;#039; +&amp;gt;&amp;#039;, &amp;#039;&amp;gt;&amp;#039;},															-- remove trailing spaces in the tag&lt;br /&gt;
		{&amp;#039; +&amp;#039;, &amp;#039; &amp;#039;},															-- remove redundant spaces&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	for _, pattern_t in ipairs (patterns_t) do&lt;br /&gt;
		span_str = span_str:gsub (pattern_t[1], pattern_t[2]);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local count = 1;&lt;br /&gt;
	while 0 ~= count do&lt;br /&gt;
		span_str, count = span_str:gsub (&amp;#039;&amp;lt;span&amp;gt;(.-)&amp;lt;/span&amp;gt;&amp;#039;, &amp;#039;%1&amp;#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return span_str;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return &lt;br /&gt;
	{&lt;br /&gt;
	math_test = math_test,														-- $...$&lt;br /&gt;
	math_test2 = math_test2,													-- \(...\)&lt;br /&gt;
	span_test = span_test,&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>imported&gt;Legoktm</name></author>
	</entry>
</feed>