nvm i solved it by putting a random unicode symbol like ⇒ to be in place of the spaces and then replaced them after the string was split by space, so it would be like {'some', 'random', '<font⇒color="rgb(255,0,0)">text</font>'}
and then in the for loop to create the items i just used string.gsub to replace the ⇒ symbols with spaces.