Add Luau syntax highlighting

Right now, DevForum users must use ```lua to highlight their Roblox code. But, certain syntax highlights in Luau are not available in Lua. After all, Luau, not Lua, is the language of us Roblox developers. Whether it be displaying a resource, asking for help, or giving code fixes, I think forum users would benefit from reading code blocks with Luau-specific syntax highlighting.

Here’s some code with Roblox Studio’s highlighting:

What we currently have with ```lua:

--!strict
type accessory = { name: string }
type drink = accessory & { color: Color3? }
type toy = accessory & { size: number?, material: string?, rarity: number? }
type chocolate = accessory & { flavor: string? }
type contestant = { drink: drink?, toy: toy?, chocolate: chocolate? }

local function round_1_requirements_check(contestant: contestant): boolean
	-- realistic contest requirements to be implemented lol
	return math.random() < 0.5
end
local contestants: { contestant } = {}

for i = 1, math.random(10, 80) do
	local contestant: contestant = {}

	-- realistic contestant generation to be implemented

	table.insert(contestants, contestant)
end

local round_1_performative: { contestant } = {}

for _, contestant in contestants do
	if not round_1_requirements_check(contestant) then
		continue
	end

	table.insert(round_1_performative, contestant)
end

The same block with ```luau: :cry: :teacup_without_handle: :chocolate_bar: :wilted_flower:

--!strict
type accessory = { name: string }
type drink = accessory & { color: Color3? }
type toy = accessory & { size: number?, material: string?, rarity: number? }
type chocolate = accessory & { flavor: string? }
type contestant = { drink: drink?, toy: toy?, chocolate: chocolate? }

local function round_1_requirements_check(contestant: contestant): boolean
	-- realistic contest requirements to be implemented lol
	return math.random() < 0.5
end
local contestants: { contestant } = {}

for i = 1, math.random(10, 80) do
	local contestant: contestant = {}

	-- realistic contestant generation to be implemented

	table.insert(contestants, contestant)
end

local round_1_performative: { contestant } = {}

for _, contestant in contestants do
	if not round_1_requirements_check(contestant) then
		continue
	end

	table.insert(round_1_performative, contestant)
end

Notice the differences? Syntax highlighting for Luau has been implemented for highlightjs, which is used by Discourse.

I believe this would be a nice low-priority QoL feature for the forum that doesn’t seem too hard to implement.

1 Like

I suggested this forever ago but they never actually added it

1 Like

Interesting. Additionally, I think it’s probably easier to implement now that the highlightjs repo for Luau syntax highlighting has been alive for ~2 years.

i’ve seen about A BILLION topics about this already, and i agree with all of them. they need to add ```luau so that developers have more accurate syntax highlighting because, imo, it makes things more convenient.

1 Like