Module:TerminalCommandGenerator: Difference between revisions

From iPhone Development Wiki
(Giving this a shot)
 
No edit summary
Line 9: Line 9:
     for i, command in ipairs(commands) do
     for i, command in ipairs(commands) do
         if i % 2 == 0 then
         if i % 2 == 0 then
             table.insert(outputs, command)
             html = html .. '<p class="term-output">' .. output .. '</p>\n'
         else
         else
            local index = (i + 1) / 2
            local output = outputs[index] or ""
             html = html .. '<p class="term-command">' .. command .. '</p>\n'
             html = html .. '<p class="term-command">' .. command .. '</p>\n'
            html = html .. '<p class="term-output">' .. output .. '</p>\n'
         end
         end
     end
     end

Revision as of 03:00, 7 October 2023

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

local p = {}


function p.generateHtml(frame)
    local commands = frame.args
    local outputs = {}
    local html = ""

    for i, command in ipairs(commands) do
        if i % 2 == 0 then
            html = html .. '<p class="term-output">' .. output .. '</p>\n'
        else
            html = html .. '<p class="term-command">' .. command .. '</p>\n'
        end
    end

    return html
end

return p