Module:TerminalCommandGenerator: Difference between revisions

From iPhone Development Wiki
No edit summary
No edit summary
Line 5: Line 5:
     local commands = frame:getParent().args
     local commands = frame:getParent().args
     local html = '<div class="terminal-' .. commands[1] .. '"><div class="term-bar"><div class="term-red"></div><span class="term-yellow"></span><span class="term-green"></span></div><div class="term-screen"><div class="term-commands">'
     local html = '<div class="terminal-' .. commands[1] .. '"><div class="term-bar"><div class="term-red"></div><span class="term-yellow"></span><span class="term-green"></span></div><div class="term-screen"><div class="term-commands">'
    table.remove(commands, 1)
     for i, command in ipairs(commands) do
     for i, command in ipairs(commands) do
         if i % 2 == 0 then
         if i == 1 then
             html = html .. '<p class="term-output">' .. command .. '</p>\n'
             html = html
         else
         else
             html = html .. '<p class="term-command">' .. command .. '</p>\n'
             if i % 2 == 0 then
                html = html .. '<p class="term-command">' .. command .. '</p>\n'
            else
                html = html .. '<p class="term-output">' .. command .. '</p>\n'
            end
         end
         end
     end
     end

Revision as of 04:21, 7 October 2023

Documentation for this module may be created at Module:TerminalCommandGenerator/doc

local p = {}


function p.generateHtml(frame)
    local commands = frame:getParent().args
    local html = '<div class="terminal-' .. commands[1] .. '"><div class="term-bar"><div class="term-red"></div><span class="term-yellow"></span><span class="term-green"></span></div><div class="term-screen"><div class="term-commands">'
    for i, command in ipairs(commands) do
        if i == 1 then
            html = html
        else
            if i % 2 == 0 then
                html = html .. '<p class="term-command">' .. command .. '</p>\n'
            else
                html = html .. '<p class="term-output">' .. command .. '</p>\n'
            end
        end
    end
    html = html .. '</div></div></div>'
    return html
end

return p