1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/contrib/lua/highlight.lua
Petr Baudis 0f6d4310ad Initial commit of the HEAD branch of the ELinks CVS repository, as of
Thu Sep 15 15:57:07 CEST 2005. The previous history can be added to this
by grafting.
2005-09-15 15:58:31 +02:00

28 lines
698 B
Lua

-- Source-code highlighting hook
-- $Id: highlight.lua,v 1.5 2005/03/25 19:02:48 miciah Exp $
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)