Open rgleichman opened 7 years ago
So are you implying that you think diagrams-svg
ought to always set xml:space="preserve"
by default? I suppose that would be more consistent with other backends; on the other hand there has never been any particular promise that text
will result in something that looks exactly the same when rendered by different backends, just that it uses the native text support provided by each backend. In which case it might make sense to have the default text output be whatever the default is. ...on the other hand, if the default were "preserve"
it would be easy for a user to implement the space-stripping behavior themselves if they really wanted it, whereas given the current situation the workaround is more fiddly and harder to discover.
So are you implying that you think diagrams-svg ought to always set xml:space="preserve" by default?
I am not advocating for a specific solution, but as far I know setting xml:space="preserve" by default would be fine. As a user, all that I would like is some way to enable xml:space="preserve" without using renderSVG' so that it's easy to switch backends.
As a user, all that I would like is some way to enable xml:space="preserve" without using renderSVG' so that it's easy to switch backends.
Ah, thanks for the clarification, that does make sense. I hadn't considered it from the point of view of switching backends. I'm guessing (but don't actually know for sure) that most, if not all, other backends essentially do something like xml:space="preserve"?
By default, SVG does not preserve spaces in text. This is explained in the SVG spec:
I am working on a visual representation of Haskell rendered using diagrams (Glance), so of course I want to preserve spaces for string literals and comments.
As a workaround, I made a customized version of renderSVG that adds the attribute
bindAttr XmlSpace_ (pack "preserve")