Skip to content

Commit

Permalink
Merge pull request #7043 from plotly/partial-strikethrough-underline-…
Browse files Browse the repository at this point in the history
…text

Add '<s>' and '<u>' pseudo html options for strike-through and underlining SVG text
  • Loading branch information
archmoj authored Jul 18, 2024
2 parents 9adfc12 + 783b877 commit 1a8369b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions draftlogs/7043_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Introduce "<u>" and "<s>" pseudo html tags to underline and strike-through SVG text elements [[#7043](https://github.com/plotly/plotly.js/pull/7043)]
2 changes: 1 addition & 1 deletion src/components/annotations/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = templatedArray('annotation', {
'Sets the text associated with this annotation.',
'Plotly uses a subset of HTML tags to do things like',
'newline (<br>), bold (<b></b>), italics (<i></i>),',
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>',
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>, <s>, <u>',
'<span> are also supported.'
].join(' ')
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ function spikesChanged(gd, oldspikepoints) {
function plainText(s, len) {
return svgTextUtils.plainText(s || '', {
len: len,
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em']
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em', 's', 'u']
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/svg_text_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ var TAG_STYLES = {
// baseline below
sup: 'font-size:70%',
sub: 'font-size:70%',
s: 'text-decoration:line-through',
u: 'text-decoration:underline',
b: 'font-weight:bold',
i: 'font-style:italic',
a: 'cursor:pointer',
Expand Down
Binary file modified test/image/baselines/pie_title_middle_center_multiline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/image/mocks/pie_title_middle_center_multiline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"data": [
{
"values": [955, 405, 360, 310, 295],
"labels": ["Mandarin", "Spanish", "English", "Hindi", "Arabic"],
"labels": ["Mandarin", "Spanish", "<u>English</u>", "Hindi", "Arabic"],
"textinfo": "label+percent",
"hole": 0.4,
"title":{
Expand All @@ -14,7 +14,7 @@
],
"layout": {
"title": {
"text": "Top 5 languages by number of native speakers (2010, est.)"
"text": "Top <s>10</s> 5 languages by number of <u>native</u> speakers (<s>2009</s> 2010, est.)"
},
"height": 600,
"width": 600
Expand Down
4 changes: 2 additions & 2 deletions test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@
"valType": "string"
},
"text": {
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported.",
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub>, <s>, <u> <span> are also supported.",
"editType": "calc+arraydraw",
"valType": "string"
},
Expand Down Expand Up @@ -6660,7 +6660,7 @@
"valType": "string"
},
"text": {
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported.",
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub>, <s>, <u> <span> are also supported.",
"editType": "calc",
"valType": "string"
},
Expand Down

0 comments on commit 1a8369b

Please sign in to comment.