HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/share/doc/elinks-data/examples/lua/highlight.lua
-- Source-code highlighting hook

highlight_file_types = {
    patch = "%.patch$",
    python = "%.py$",
    perl = "%.pl$",
    awk = "%.awk$",
    c = "%.[ch]$",
    sh = "%.sh$",
}

function highlight (url, html)
    for language,pattern in pairs(highlight_file_types) do
        if string.find (url, pattern) then
            local tmp = tmpname ()
            writeto (tmp) write (html) writeto()
            html = pipe_read ("(code2html -l "..language.." "..tmp.." - ) 2>/dev/null")
            os.remove(tmp)
            return html,nil
        end
    end

    return nil,nil
end

table.insert(pre_format_html_hooks, highlight)