Concatenate Text with background color with other Texts in SwiftUI

I'm willing to render a rich text using SwiftUI, and I'm able to achieve almost all I need with the Text concatenation approach, like:
Text("Test ").foregroundColor(.red) + Text("test").fontWeight(.black)

But, I'm lacking a way to set background color to sub-strings of the text, since the .background() modifier returns a View instead of a Text.

Is there a way or a workaround to set background color to sub-strings within a block of text?
As far as I know, there's no way.
(Unless you want to treat the text with background as a separate view than other texts.)

You may need to work with UIViewRepresentable and NSAttributedString.
Concatenate Text with background color with other Texts in SwiftUI
 
 
Q