Skip to content

Commit dedce75

Browse files
committed
Highlight LLVM code using the InteractiveUtils stdlib.
1 parent edef568 commit dedce75

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/reflection.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ end
1919
function highlight(io::IO, code, lexer)
2020
highlighter = pygmentize()
2121
have_color = get(io, :color, false)
22-
if highlighter === nothing || !have_color
22+
if !have_color
2323
print(io, code)
24-
else
24+
elseif lexer == "llvm"
25+
InteractiveUtils.print_llvm(io, code)
26+
elseif highlighter !== nothing
2527
custom_lexer = joinpath(dirname(@__DIR__), "res", "pygments", "$lexer.py")
2628
if isfile(custom_lexer)
2729
lexer = `$custom_lexer -x`
@@ -31,6 +33,8 @@ function highlight(io::IO, code, lexer)
3133
print(pipe, code)
3234
close(pipe.in)
3335
print(io, read(pipe, String))
36+
else
37+
print(io, code)
3438
end
3539
return
3640
end

0 commit comments

Comments
 (0)