local syntax_highlighter = game:GetService("HttpService"):JSONDecode([[{"name":"My Syntax Highlighter","version":"1.0","language":"lua","author":"John Doe","keywords":[{"name":"if","color":"#0000FF"},{"name":"else","color":"#0000FF"},{"name":"function","color":"#0000FF"},{"name":"local","color":"#0000FF"},{"name":"for","color":"#0000FF"}],"operators":[{"name":"+","color":"#00AA00"},{"name":"-","color":"#00AA00"},{"name":"*","color":"#00AA00"},{"name":"/","color":"#00AA00"},{"name":"%","color":"#00AA00"}],"strings":{"color":"#AA0000"},"comments":{"color":"#808080","prefix":"--"}}]])
function add_colors(code)
for _, keyword in ipairs(syntax_highlighter.keywords) do
code = code:gsub("(%s)"..keyword.name.."(%s)", "%1<font color='"..keyword.color.."'>"..keyword.name.."</font>%2")
end
for _, operator in ipairs(syntax_highlighter.operators) do
code = code:gsub("("..operator.name..")", "<font color='"..operator.color.."'>%1</font>")
end
code = code:gsub("([\"'])(.-)%1", "<font color='"..syntax_highlighter.strings.color.."'>%1%2%1</font>")
code = code:gsub("("..syntax_highlighter.comments.prefix..".-)$", "<font color='"..syntax_highlighter.comments.color.."'>%1</font>")
return code
end
print(add_colors("print('Hello, World!')"))