Skip to content

Commit

Permalink
Merge pull request danielearwicker#35 from creately/fix-ampersand
Browse files Browse the repository at this point in the history
Fix ampersand
  • Loading branch information
thani-sh authored Jul 15, 2019
2 parents 26dcc9f + 61d91eb commit c7e8178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion src/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c7e8178

Please sign in to comment.