Skip to content

Commit

Permalink
Replace himalay with join/split, see phetsims/scenery#1314 and for ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Aug 29, 2022
1 parent 54cf13e commit 2c543b0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build/utterance-queue.min.js

Large diffs are not rendered by default.

19 changes: 1 addition & 18 deletions js/SpeechSynthesisAnnouncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,29 +730,12 @@ class SpeechSynthesisUtteranceWrapper {
}
}

type HimalayaElement = {
type: string;
tagName: string;
};
/**
* @param element - returned from himalaya parser, see documentation for details.
*/
const isNotBrTag = ( element: HimalayaElement ): boolean => !( element.type.toLowerCase() === 'element' && element.tagName.toLowerCase() === 'br' );

/**
* Remove <br> or <br/> tags from a string
* @param string - plain text or html string
*/
function removeBrTags( string: string ): string {

// @ts-ignore - factor out usages of global to a single spot for one ts-ignore
const parser = himalaya;

if ( parser ) {
const parsedAndFiltered = parser.parse( string ).filter( isNotBrTag );
return parser.stringify( parsedAndFiltered );
}
return string;
return string.split( '<br/>' ).join( ' ' ).split( '<br>' ).join( ' ' );
}

const SpeechSynthesisVoiceIO = new IOType( 'SpeechSynthesisVoiceIO', {
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
"phet.utteranceQueue": "UTTERANCE_QUEUE/main",
"phet.phetCore": "PHET_CORE/main",
"phet.axon": "AXON/main"
},
"preload": [
"../sherpa/lib/himalaya-1.1.0.js"
]
}
},
"eslintConfig": {
"extends": "../chipper/eslint/sim_eslintrc.js",
"globals": {
"himalaya": "readonly",
"SpeechSynthesis": "readonly",
"SpeechSynthesisVoice": "readonly",
"SpeechSynthesisUtterance": "readonly"
Expand Down
6 changes: 1 addition & 5 deletions utterance-queue-tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@
"phet.utteranceQueue": "UTTERANCE_QUEUE/main",
"phet.phetCore": "PHET_CORE/main",
"phet.axon": "AXON/main"
},
"preload": [
"../sherpa/lib/himalaya-1.1.0.js"
]
}
},
"eslintConfig": {
"extends": "../chipper/eslint/sim_eslintrc.js",
"globals": {
"himalaya": "readonly",
"SpeechSynthesis": "readonly",
"SpeechSynthesisVoice": "readonly",
"SpeechSynthesisUtterance": "readonly"
Expand Down

0 comments on commit 2c543b0

Please sign in to comment.