From c362a1de861c0b77f8ba0edcff9c9d0013453aef Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Thu, 8 Dec 2022 12:15:08 -0700 Subject: [PATCH] Wrap chemical formulas in LTR marks, see https://github.com/phetsims/chipper/issues/1355 --- js/util/StringUtils.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/util/StringUtils.js b/js/util/StringUtils.js index 52482e59..14722c74 100644 --- a/js/util/StringUtils.js +++ b/js/util/StringUtils.js @@ -284,6 +284,28 @@ var StringUtils = { return string.replace( /\u202a/g, '[LTR]' ).replace( /\u202b/g, '[RTL]' ).replace( /\u202c/g, '[POP]' ); }, + /** + * Wraps a string with embedding marks for LTR display. + * @public + * + * @param {string} string + * @returns {string} + */ + wrapLTR: function( string ) { + return LTR + string + POP; + }, + + /** + * Wraps a string with embedding marks for RTL display. + * @public + * + * @param {string} string + * @returns {string} + */ + wrapRTL: function( string ) { + return LTR + string + POP; + }, + /** * Assert that a template var is in a string. Useful for translated strings with a template var pattern like * "Hello {{meanName}}" --> "Hello goofball". See StringUtils.fillIn() for base usages of template var pattern.