How to make an HTML syntax highlighter?

I want to make a textbox that highlights HTML code.
Is there a module for that?

Probably not, you would need to make one yourself.

Not that I know of. My experience with making a syntax highlighter inside Roblox is using string functions such as string.gsub() and string.find().

More information here:

https://developer.roblox.com/en-us/api-reference/lua-docs/string

Some more resources:

That’s really close but I need it the other way around where I can have a roblox textbox with html in it and highlight all the syntax

I’ll make a module in about an hour I can start. I’ll post back here once it’s done.

That would be really helpful! Thanks.

Alright well, it’s not done but I won’t be able to work on it anymore until tomorrow. Right now it basically only highlights HTML tags and attributes (basically class, id, placeholder). Tomorrow I will try to continue to work on this and add the highlighting of strings and more!

Anyways, quick example (NOTE: Make sure rich text is enabled!)

local Label = script.Parent
local Syntact = require(10504757324)

local html = [[
<body>
	<h1>Hello world!</h1>
	<input type="text" placeholder="Name Here" id="Name Input" class="name" />
</body>
]]

local Highlighter = Syntact.new(html)
Label.Text = Highlighter:Highlight("HTML")
1 Like

Support for strings and comments have been added!

1 Like