diff --git a/package.json b/package.json index cced879..35bd636 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@creately/carota", "author": "Daniel Earwicker (dan@earwicker.com)", "description": "Simple, flexible rich text rendering/editing on HTML Canvas", - "version": "2.9.0", + "version": "2.9.1", "repository": { "type": "git", "url": "https://github.com/danielearwicker/carota.git" diff --git a/src/doc.js b/src/doc.js index b6cd02d..3bb4f74 100644 --- a/src/doc.js +++ b/src/doc.js @@ -150,7 +150,10 @@ var prototype = node.derive({ baseline: line.baseline, left, content: { - text: text.run.text.trim() + ' '.repeat( word.space.length ), + // replace( /&(?!#?[a-z0-9]+;)/, '&' ) is to replace ampersand char with '&' + // as `&` can't be rendered in an SVG text + // The regex explainer https://regex101.com/r/4vhX9N/1 + text: text.run.text.trim().replace( /&(?!#?[a-z0-9]+;)/, '&' ) + ' '.repeat( word.space.length ), size: text.run.size || this.defaultFormatting.size, font: text.run.font || this.defaultFormatting.font, color: text.run.color || this.defaultFormatting.color,