1
0
Fork 0

Do not escape text in plugin, instead escape at render time

This commit is contained in:
Joost De Cock 2020-03-15 12:20:48 +01:00
parent 332b28e618
commit e9784509ee
3 changed files with 24 additions and 5 deletions

View file

@ -182,7 +182,7 @@ Svg.prototype.renderPathText = function(path) {
let svg = this.nl() + '<text>'
this.indent()
svg += `<textPath xlink:href="#${path.attributes.get('id')}" ${offset}><tspan ${attributes}>${
this.text
this.escapteText(this.text)
}</tspan></textPath>`
this.outdent()
svg += this.nl() + '</text>'
@ -214,7 +214,8 @@ Svg.prototype.renderText = function(point) {
svg += `<tspan x="${point.x}" dy="${lineHeight}">${line}</tspan>`
}
} else {
svg += `<tspan>${this.text}</tspan>`
svg += `<tspan>${this.escapeText(this.text)
}</tspan>`
}
this.outdent()
svg += this.nl() + '</text>'
@ -222,6 +223,10 @@ Svg.prototype.renderText = function(point) {
return svg
}
Svg.prototype.escapeText = function(text) {
return text.replace('"', '&#8220;')
}
Svg.prototype.renderCircle = function(point) {
return `<circle cx="${point.x}" cy="${point.y}" r="${point.attributes.get(
'data-circle'