nbsp; in svgs.
Closed this issue · 4 comments
When I use the tool to generate svgs - they contain but isn't actually legal in svg files. When I try to open them as svg file instead of embedded into an html, they produce errors.
As far as I know, there isn't a good reason to be escaping spaces. Certainly, its not correct to uniformly convert spaces into non-breaking spaces.
How does you use the tool? CLI or the JS library.
In CLI I do distinguish the context on whether a SVG would like to be inlined in HTML or as a individual SVG file.
typst.ts/exporter/svg/src/backend/mod.rs
Lines 180 to 184 in 5121d2e
typst.ts/exporter/svg/src/lib.rs
Line 111 in 5121d2e
But in JS library I was lazy and assumed users always embed them into some HTML element. But anyway, I'll let JS library aware of that that in next release.
I am using the JS library.
Rather than putting an option in, I'd suggest using  
instead of
This should work no matter how the svg is used.
Still better, I think, would be to not escape whitespace at all, but set white-space: pre
in the css file.
I'd like to contribute back by sending you a PR, if you'd be amenable to one of my proposals.
I like the second one. That is very smart. We can set white-space for only the pseudo text elements by a css class selector .tsel
, which should work.