<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser%3ALayer-09%2FSandbox%2FCommand.lua</id>
	<title>Module:User:Layer-09/Sandbox/Command.lua - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser%3ALayer-09%2FSandbox%2FCommand.lua"/>
	<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Module:User:Layer-09/Sandbox/Command.lua&amp;action=history"/>
	<updated>2026-04-03T18:13:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.0</generator>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Module:User:Layer-09/Sandbox/Command.lua&amp;diff=22541&amp;oldid=prev</id>
		<title>Layer-09: .</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Module:User:Layer-09/Sandbox/Command.lua&amp;diff=22541&amp;oldid=prev"/>
		<updated>2025-06-08T08:36:56Z</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 p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local parent = frame:getParent()&lt;br /&gt;
    local args = parent.args&lt;br /&gt;
    &lt;br /&gt;
    local content = args[1] or &amp;#039;&amp;#039;&lt;br /&gt;
    local type = mw.text.trim(args.type or &amp;#039;command&amp;#039;)&lt;br /&gt;
    &lt;br /&gt;
    -- Handle empty content&lt;br /&gt;
    if content == &amp;#039;&amp;#039; then&lt;br /&gt;
        return &amp;#039;&amp;lt;div class=&amp;quot;mw-command-block&amp;quot;&amp;gt;&amp;lt;em&amp;gt;No command specified&amp;lt;/em&amp;gt;&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    local lines = mw.text.split(content, &amp;#039;\n&amp;#039;)&lt;br /&gt;
    local is_multiline = #lines &amp;gt; 1&lt;br /&gt;
    &lt;br /&gt;
    -- Create the main container&lt;br /&gt;
    local root = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
    root:addClass(&amp;#039;mw-command-block&amp;#039;)&lt;br /&gt;
    &lt;br /&gt;
    -- Add the copy button&lt;br /&gt;
    local copyButton = root:tag(&amp;#039;button&amp;#039;)&lt;br /&gt;
    copyButton:addClass(&amp;#039;mw-copy-button&amp;#039;)&lt;br /&gt;
        :attr(&amp;#039;type&amp;#039;, &amp;#039;button&amp;#039;)&lt;br /&gt;
        :attr(&amp;#039;title&amp;#039;, &amp;#039;Copy to clipboard&amp;#039;)&lt;br /&gt;
        :wikitext(&amp;#039;Copy&amp;#039;)&lt;br /&gt;
        &lt;br /&gt;
    -- Create the area for all code lines&lt;br /&gt;
    local codeArea = root:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
    codeArea:addClass(&amp;#039;mw-code-area&amp;#039;)&lt;br /&gt;
    &lt;br /&gt;
    -- Loop through each line and build the structure&lt;br /&gt;
    for i, line in ipairs(lines) do&lt;br /&gt;
        local line_container = codeArea:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
        line_container:addClass(&amp;#039;mw-code-line&amp;#039;)&lt;br /&gt;
        &lt;br /&gt;
        -- Build the prefix string&lt;br /&gt;
        local prefix_str = &amp;#039;&amp;#039;&lt;br /&gt;
        if is_multiline then&lt;br /&gt;
            prefix_str = string.format(&amp;#039;%2d&amp;#039;, i) -- Right-align line numbers&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if type == &amp;#039;command&amp;#039; then&lt;br /&gt;
            if is_multiline then&lt;br /&gt;
                prefix_str = prefix_str .. &amp;#039;  $ &amp;#039;&lt;br /&gt;
            else&lt;br /&gt;
                prefix_str = &amp;#039;$ &amp;#039;&lt;br /&gt;
            end&lt;br /&gt;
        elseif is_multiline then&lt;br /&gt;
            prefix_str = prefix_str .. &amp;#039;   &amp;#039; -- Add spacing for alignment&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        -- Create the prefix span&lt;br /&gt;
        if prefix_str ~= &amp;#039;&amp;#039; then&lt;br /&gt;
            line_container:tag(&amp;#039;span&amp;#039;)&lt;br /&gt;
                :addClass(&amp;#039;mw-code-prefix&amp;#039;)&lt;br /&gt;
                :wikitext(prefix_str)&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        -- Create the code element&lt;br /&gt;
        local code_element = line_container:tag(&amp;#039;code&amp;#039;)&lt;br /&gt;
        code_element:addClass(&amp;#039;mw-code-text&amp;#039;)&lt;br /&gt;
        &lt;br /&gt;
        -- Handle empty lines properly&lt;br /&gt;
        if mw.text.trim(line) == &amp;#039;&amp;#039; then&lt;br /&gt;
            code_element:wikitext(&amp;#039;&amp;amp;#8203;&amp;#039;) -- Zero-width space to maintain line height&lt;br /&gt;
        else&lt;br /&gt;
            -- Clean up the line and add it&lt;br /&gt;
            local clean_line = line:gsub(&amp;#039;^%s+&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;%s+$&amp;#039;, &amp;#039;&amp;#039;) -- Trim whitespace&lt;br /&gt;
            code_element:wikitext(line) -- Keep original spacing&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Layer-09</name></author>
	</entry>
</feed>