Module:TerminalCommandGenerator: Difference between revisions

From iPhone Development Wiki
(Giving this a shot)
(No difference)

Revision as of 02:26, 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
            table.insert(outputs, command)
        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-output">' .. output .. '</p>\n'
        end
    end

    return html
end

return p