Ignore rich text markup in strings?

I have a system in my game where people can send messages to other servers. I use richtext markup to color the usernames of people, but when people use things such as “<” the richtext freaks out as seen here, where someone wanted to post <3.

How do i make it so it ignores any rich text markup in the user generated string?


I think you should either maker a new textbox, or block certain characters.

1 Like

Actually, just insert a zero width non-joiner character after each character the user gives.

Try replacing < and > with &lt; and &gt;


Creating two text labels like @bluechristmas20181 mentioned is quite straightforward. I don’t know about zero width non-joiners, but if you opt to keep one text label, you can also iterate it and replace these few characters in question with their escape forms:

local escapeForms = {
    ["<"] = "&lt;";
    [">"] = "&gt;";
    ['"'] = "&quot;";
    ["'"] = "&apos;";
    ["&"] = "&amp;";

local message = "Hi <3"
message = string.gsub(message, ".", function(c)
    return escapeForms[c] or c

Edit. @thedauser beat me to it :slight_smile:

Edit 2. The table contains entities for tag chars listed here: Creator Hub - Rich Text Markup - Escape Forms.


Or use HTML escape entities, that’s probably better

Thanks a lot, that fixes it! I am never really good with text markup, so im glad you could figure it out

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.