Skip to content

Commit

Permalink
Wrap chemical formulas in LTR marks, see phetsims/chipper#1355
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed May 15, 2024
1 parent 0240547 commit 1234e4f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions js/util/StringUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,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.
Expand Down

0 comments on commit 1234e4f

Please sign in to comment.