Im basically trying to recreate the roblox studio script editor in roblox, and to be frank. the string formatting has been giving me hell, ive managed to get it to work with ’ OR " however I wish for them both to work simultaneously similar to how roblox processes it.
Function
function module.StringHighlighting(String, Term, Extra)
local StringPosition = string.find(String, Term)
if StringPosition then
local Remainder = string.sub(String, StringPosition, #String)
String = string.sub(String, 1, StringPosition-1)
local EndStringPosition = string.find(string.sub(Remainder,2,#Remainder), Term)
if EndStringPosition then
table.insert(StringParts, TableCount + Extra, '<font color= "rgb('.. PlayerPreferences.ScriptEditorAsthetics['BuiltInStringColor'] ..' )">'.. string.sub(Remainder, 1, EndStringPosition+1).. "</font>")
local LastPortion = string.sub(Remainder, EndStringPosition+2, #Remainder)
TableCount = TableCount + 1
local CurrentTableCount = TableCount + Extra
LastPortion = module.StringHighlighting(LastPortion, Term, Extra + 1)
LastPortion = module.StandardSyntaxFormatting(LastPortion)
table.insert(StringParts, CurrentTableCount, LastPortion)
TableCount = TableCount + 1
else
table.insert(StringParts, TableCount + Extra,'<font color= "rgb('.. PlayerPreferences.ScriptEditorAsthetics['BuiltInStringColor'] ..' )">'.. Remainder.. "</font>")
TableCount = TableCount + 1
end
end
return String
end
Inputs:
String = module.StringHighlighting(String, "'", 0)
Where string is just any string of text
Ive tried numerous solutions however they all result in really weird disfiguration of the text and are inefficient, any help would be appreciated.