https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ASu%2Fsandbox2 Module:Su/sandbox2 - Revision history 2025-05-31T11:36:23Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.3 https://en.wikipedia.org/w/index.php?title=Module:Su/sandbox2&diff=1234374455&oldid=prev Ahecht: create from Module:Su/sandbox 2024-07-14T01:20:17Z <p>create from <a href="/wiki/Module:Su/sandbox" title="Module:Su/sandbox">Module:Su/sandbox</a></p> <p><b>New page</b></p><div>-- This module implements {{su}}.<br /> <br /> local p = {}<br /> <br /> function p.main(frame)<br /> -- Use arguments from the parent frame only, and remove any blank arguments.<br /> -- We don&#039;t need to trim whitespace from any arguments, as this module only<br /> -- uses named arguments, and whitespace is trimmed from them automatically. <br /> local origArgs = frame:getParent().args<br /> local args = {}<br /> for k, v in pairs(origArgs) do<br /> if v ~= &#039;&#039; then<br /> args[k] = v<br /> end<br /> end<br /> <br /> -- Define the variables to pass to luaMain.<br /> local sup = args.p<br /> local sub = args.b<br /> local options = {<br /> align = args.a,<br /> fontSize = args.w,<br /> lineHeight = args.lh,<br /> verticalAlign = args.va<br /> }<br /> return p._main(sup, sub, options)<br /> end<br /> <br /> function p.invoke_main(frame)<br /> -- entry point for invocation using frame arguments<br /> <br /> local origArgs = frame.args<br /> local args = {}<br /> for k, v in pairs(origArgs) do<br /> if v ~= &#039;&#039; then<br /> args[k] = v<br /> end<br /> end<br /> <br /> -- Define the variables to pass to luaMain.<br /> local sup = args.p<br /> local sub = args.b<br /> local options = {<br /> align = args.a,<br /> fontSize = args.w,<br /> lineHeight = args.lh,<br /> verticalAlign = args.va<br /> }<br /> return p._main(sup, sub, options)<br /> end<br /> <br /> function p._main(sup, sub, options)<br /> options = options or {}<br /> local span = mw.html.create(&#039;span&#039;):addClass(&#039;nowrap&#039;)<br /> <br /> -- Set the styles.<br /> span:css{<br /> [&#039;display&#039;] = &#039;inline-block&#039;,<br /> [&#039;margin-bottom&#039;] = &#039;-0.3em&#039;,<br /> [&#039;vertical-align&#039;] = options.verticalAlign or sub and &#039;-0.4em&#039; or &#039;0.8em&#039;,<br /> [&#039;line-height&#039;] = options.lineHeight or &#039;1.2em&#039;<br /> }<br /> if options.fontSize == &#039;f&#039; or options.fontSize == &#039;fixed&#039; then<br /> span:css{<br /> [&#039;font-family&#039;] = &#039;monospace&#039;,<br /> [&#039;font-size&#039;] = &#039;80%&#039;<br /> }<br /> else<br /> span:css(&#039;font-size&#039;, options.fontSize or &#039;80%&#039;)<br /> end<br /> if options.align == &#039;r&#039; or options.align == &#039;right&#039; then<br /> span:css(&#039;text-align&#039;, &#039;right&#039;)<br /> elseif options.align == &#039;c&#039; or options.align == &#039;center&#039; then<br /> span:css(&#039;text-align&#039;, &#039;center&#039;)<br /> else<br /> span:css(&#039;text-align&#039;, &#039;left&#039;)<br /> end<br /> <br /> -- Add the wikitext.<br /> span<br /> :wikitext(&#039;&amp;NoBreak;&#039;)<br /> :tag(&#039;sup&#039;)<br /> :css(&#039;font-size&#039;, &#039;inherit&#039;)<br /> :css(&#039;line-height&#039;, &#039;inherit&#039;)<br /> :css(&#039;vertical-align&#039;, &#039;baseline&#039;)<br /> :wikitext(sup)<br /> :done()<br /> :tag(&#039;br&#039;, {selfClosing = true}):done()<br /> :tag(&#039;sub&#039;)<br /> :css(&#039;font-size&#039;, &#039;inherit&#039;)<br /> :css(&#039;line-height&#039;, &#039;inherit&#039;)<br /> :css(&#039;vertical-align&#039;, &#039;baseline&#039;)<br /> :wikitext(sub)<br /> :wikitext(&#039;&amp;NoBreak;&#039;)<br /> <br /> return tostring(span)<br /> end<br /> <br /> return p</div> Ahecht