Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Escaping of text elements #46

@git-afsantos

Description

@git-afsantos

Text elements that include special charaters are being incorrectly exported. For instance, when I have text elements with the text <trigger>, the generated SVG is

<text transform="matrix(1,0,0,1,0,0)" style="text-anchor: end; font: normal normal normal 10px/normal Arial;" x="161" y="31.5" text-anchor="end" font="10px &quot;Arial&quot;" stroke="none" fill="#000"><tspan dy="3.634615384615385"><trigger></tspan></text>

That <trigger> tag is parsed as a regular SVG tag, and isn't displayed in the resulting SVG image.

In the 'text' serializer, line 209, I've replaced

tags.push(tag(
    'text',
    attrs,
    node.matrix,
    tag('tspan', {
        dy: computeTSpanDy(style.font.size, line + 1, totalLines)
    }, null, text.replace(/&/g, "&amp;"))
));

with

tags.push(tag(
    'text',
    attrs,
    node.matrix,
    tag('tspan', {
        dy: computeTSpanDy(style.font.size, line + 1, totalLines)
    }, null, escapeXML(text.replace(/&/g, "&amp;")))
));

and that seems to do the trick, thus far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions