Is it possible to give padding to a range of text like html inline block?
I find an app that uses native rendering to display a markdown code block:
But I've no idea how they implement it.
It has both:
- round corner
- background color
- no extra space
I noticed selection range at edge looks a bit wider than the char itself:
You can use insets on BackgroundStyle to add additional padding on any of the sides of the background. Have a look at the documentation here.
In the screenshot that you have shared in your comment, it seems that there is likely a half-space or no-break-space character used that is what is showing you additional padding in selection. You can use no-break-space like this:
let noBreakSpace = "\u{00a0}"
let text = "\(noBreakSpace)Test\(noBreakSpace)"
If you use noBreakSpace, you would not need to use insets on BackgroundStyle.