diff --git a/src/constants/string_mappings.js b/src/constants/string_mappings.js index a2760f7b6c0..55c4a512317 100644 --- a/src/constants/string_mappings.js +++ b/src/constants/string_mappings.js @@ -10,27 +10,32 @@ 'use strict'; // N.B. HTML entities are listed without the leading '&' and trailing ';' +// https://www.freeformatter.com/html-entities.html module.exports = { - entityToUnicode: { 'mu': 'μ', + '#956': 'μ', + 'amp': '&', + '#28': '&', + 'lt': '<', + '#60': '<', + 'gt': '>', + '#62': '>', + 'nbsp': ' ', + '#160': ' ', + 'times': '×', + '#215': '×', + 'plusmn': '±', - 'deg': '°' - }, - - unicodeToEntity: { - '&': 'amp', - '<': 'lt', - '>': 'gt', - '"': 'quot', - '\'': '#x27', - '\/': '#x2F' - } + '#177': '±', + 'deg': '°', + '#176': '°' + } }; diff --git a/test/jasmine/tests/svg_text_utils_test.js b/test/jasmine/tests/svg_text_utils_test.js index 4a118295b80..374d50b9e8e 100644 --- a/test/jasmine/tests/svg_text_utils_test.js +++ b/test/jasmine/tests/svg_text_utils_test.js @@ -262,6 +262,15 @@ describe('svg+text utils', function() { expect(node.text()).toEqual('100μ & < 10 > 0  100 × 20 ± 0.5 °'); }); + it('decodes some HTML entities in text (number case)', function() { + var node = mockTextSVGElement( + '100μ  < 10 > 0  ' + + '100 × 20 ± 0.5 °' + ); + + expect(node.text()).toEqual('100μ & < 10 > 0  100 × 20 ± 0.5 °'); + }); + it('supports superscript by itself', function() { var node = mockTextSVGElement('123'); expect(node.html()).toBe(