Module:TerminalCommandGenerator: Difference between revisions

From iPhone Development Wiki
(Try and fix this formatting issue)
m (Well that didn't work, lets try this)
 
Line 10: Line 10:
         else
         else
             if i % 2 == 0 then
             if i % 2 == 0 then
                 html = html .. '<p class="term-command">' ..mw.text.nowiki(command):gsub('\n', '<br>'):gsub(' ', '&#20;') .. '</p>\n'
                 html = html .. '<p class="term-command">' ..mw.text.nowiki(command):gsub('\n', '<br>'):gsub(' ', '&emsp;') .. '</p>\n'
             else
             else
                 html = html .. '<p class="term-output">' .. mw.text.nowiki(command):gsub('\n', '<br>'):gsub(' ', '&#20;') .. '</p>\n'
                 html = html .. '<p class="term-output">' .. mw.text.nowiki(command):gsub('\n', '<br>'):gsub(' ', '&emsp;') .. '</p>\n'
             end
             end
         end
         end

Latest revision as of 14:43, 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">' ..mw.text.nowiki(command):gsub('\n', '<br>'):gsub(' ', '&emsp;') .. '</p>\n'
            else
                html = html .. '<p class="term-output">' .. mw.text.nowiki(command):gsub('\n', '<br>'):gsub(' ', '&emsp;') .. '</p>\n'
            end
        end
    end
    html = html .. '</div></div></div>'
    return html
end

return p