diff options
author | ubq323 <ubq323@ubq323.website> | 2024-11-28 11:44:39 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-11-28 11:44:42 +0000 |
commit | c7d9efdb19b650733f19176e11389e865ee92272 (patch) | |
tree | 5b2b4c90dee59059c23baad9ff89b24c63328231 | |
parent | 16e9f4ef0ab0ad51a7a05fd98ee1870c81b20a73 (diff) |
-rw-r--r-- | init.lua | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -3,16 +3,11 @@ local T = html.T local prose = require'garkup.prose' local function highlight(code, lang) - -- you'd better not already be using that file - local infile = assert(io.open("/tmp/highlighter_input","w")) - assert(infile:write(code)) - local outhandle = assert(io.popen("highlight -f -S "..lang.." --inline-css --enclose-pre </tmp/highlighter_input", "r")) - local output = assert(outhandle:read"a") - - outhandle:close() - infile:close() - - return html.safe(output) + local run = require'run' + return html.safe(run{ + "highlight", "-f", "-S", lang, "--inline-css", "--enclose-pre", + input = code, + }) end local function mode_code(S) |