Inkscape.org
Beyond the Basics Reformatting SVG XML looses almost all text
  1. #1
    fer25 fer25 @fer25

    I used inkscape to create another block diagram. This time around, I wanted to add lots of javascript highlighting and tooltips. So I wrote a libxml based script to edit the SVG and add extra class attributes. The edited SVG looks fine in Firefox, but in Inkscape almost all the text has disappeared. I changed my libxml based script to simply read and rewrite the SVG and did a ton of work to prove the before and after were equivilent. As the white space formatting of the before and after XML is drastically different. This happens with several Inkscape versions including 1.4.2

    I enclose two small SVGs which show the problem. s2.svg is from Inkscape and s4.svg is rewritten version. One of the labels is missing from s4.svg. 

    I suspect this is a bug or undesirable behaviour in Inkscape, but I would love to know if there is a work around.

    S4
    S2
  2. #2
    karliss karliss @karliss

    Took a look at the files. The differences which is causing inkscape to interpret the file differently are the extra whitespaces you are adding in text tags.

    The original looks something like this:

    <text><tspan>t3</tspan></text>

    After the changes it becomes
        <text>
        <tspan>t3</tspan>
        </text>


    There are 2 x 4 additional whitespace symbols inside text tags, you can even select them within inkscape. Handling xml  parts that function as markup where subsections of text content are wrapped in tags is tricky. Would have to read the SVG spec to tell what's the exact intended behavior. 

  3. #3
    fer25 fer25 @fer25

    Thanks very much. You nailed it. Removing all white space within text XML elements fixes things.

    I must read up on the SVG text tag - after all it is interesting that browsers render the text OK, it is AFAIK only Inkscape that fails.

    Regards

  4. #4
    fer25 fer25 @fer25

    Looking into this a bit more, it is probably related to inkscapes advanced text flow features which browsers do no support.

Inkscape Inkscape.org Inkscape Forum Beyond the Basics Reformatting SVG XML looses almost all text