Discourse syntax highlighting?

I agree, there’s perhaps a couple things that might not have carried over from the blogpost (new version of hljs, maybe? or just the theme settings?) but still, quite a big improvement!

Before:

After:

4 Likes

Just as an update, I’ve now put this “Theme Component” into a git repository here: GitHub - JuliaDiscourse/Unleashed-Julia-Syntax-Highlighting: Discourse Component with extended highlights definitions for Julia. When new commits are pushed to main, admins here get notified of the update in the admin dashboard here and can pull them into the deployed site. PRs welcome! There’s not, AFAIK, an easy way to preview changes, unfortunately. But it’s easy enough to roll back if there’s trouble.

I’ve made a few more changes over the past few days:

  • The default (unadorned) ``` syntax will try to auto-detect between julia and julia-repl. There’s generally no need to explicitly specify either one. You can, of course, still specify any of the supported languages.
  • I’ve enabled support for styling the IR, LLVM, and ASM outputs from the julia> prompt where a code_* introspection function or macro is the first thing on the line.
  • The REPL banner will also be tagged as a “comment”

the code for the above image
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.6 (2025-07-09)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> @code_typed 1+2
CodeInfo(
1 ─ %1 = intrinsic Base.add_int(x, y)::Int64
└──      return %1
) => Int64

julia> @code_llvm 1+2
; Function Signature: +(Int64, Int64)
;  @ int.jl:87 within `+`
define i64 @"julia_+_4796"(i64 signext %"x::Int64", i64 signext %"y::Int64") #0 {
top:
  %0 = add i64 %"y::Int64", %"x::Int64"
  ret i64 %0
}

julia> @code_native 1+2
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 15, 0
	.globl	"_julia_+_4800"                 ; -- Begin function julia_+_4800
	.p2align	2
"_julia_+_4800":                        ; @"julia_+_4800"
; Function Signature: +(Int64, Int64)
; ┌ @ int.jl:87 within `+`
; %bb.0:                                ; %top
	;DEBUG_VALUE: +:x <- $x0
	;DEBUG_VALUE: +:x <- $x0
	;DEBUG_VALUE: +:y <- $x1
	;DEBUG_VALUE: +:y <- $x1
	add	x0, x1, x0
	ret
; └
                                        ; -- End function
.subsections_via_symbols
12 Likes