BEGIN { highlight_cmd = ENVIRON["HIGHLIGHT"] " -O html -f -S " # expected language name in the end! highlight_out = "/tmp/__fragment" highlight_langs = "awk,bat,bison,y,bash,sh,zsh,yacc,c,cpp,h,hpp,csharp,cs,css," \ "diff,patch,dockerfile,email,go,haskell,hs,html,htm,xhtml," \ "httpd,ini,cfg,desktop,java,gradle,javascript,js,json,kotlin," \ "lisp,cl,clisp,sbcl,lua,makefile,mk,markdown,md,meson,mssql," \ "nix,perl,pl,php,python,py,qmake,rust,rs,s,sql,svg,tex,toml,xml,yaml" } ENVIRON["HIGHLIGHT"] && language && blocks_names[blocks_opened] == "CODE" { hl_lang = tolower(language) if (hl_lang == "yacc") hl_lang = "y" if (hl_lang == "latex") hl_lang = "tex" transcludes_file = toupper($1) == "'INCLUDE" || toupper($1) == "'SNIPPET" if (highlight_langs ~ hl_lang && (transcludes_file || !/^[ \t]*'/)) { __tmp = FILE_EXTENSION FILE_EXTENSION = "" if (transcludes_file) process_command(toupper(substr($1, 2))) highlight = highlight_cmd hl_lang " > " highlight_out print | highlight close(highlight) $0 = getfile(highlight_out) gsub(/\\/, "\\\\") FILE_EXTENSION = __tmp } }