@@ -281,6 +281,33 @@ Short format
281281} ) ;
282282
283283describe ( "caption formatting" , ( ) => {
284+ it . each ( [
285+ [ "R&D <config> next" , "R&D <config> next" ] ,
286+ [ "Literal < & references" , "Literal &lt; &amp; references" ] ,
287+ [ "3 < 4 and 5 > 2" , "3 < 4 and 5 > 2" ] ,
288+ [ "R&D --> next" , "R&D --> next" ] ,
289+ ] ) ( "preserves literal WebVTT text %j on export and reimport" , ( text , payload ) => {
290+ const words = [ { text, start : 1 , end : 2 , id : "w0" } ] ;
291+ const output = formatVtt ( words ) ;
292+ expect ( output ) . toBe ( `WEBVTT\n\n00:00:01.000 --> 00:00:02.000\n${ payload } \n` ) ;
293+ expect ( loadTranscript ( tmpFile ( "literal.vtt" , output ) ) . words ) . toEqual ( words ) ;
294+ } ) ;
295+
296+ it . each ( [
297+ [ "R&D <config> next" , "R&D <config> next" ] ,
298+ [ ""quoted" 'text'" , "\"quoted\" 'text'" ] ,
299+ [ "& < <" , "& < <" ] ,
300+ [ "Literal &lt; &amp; references" , "Literal < & references" ] ,
301+ [ "<b>R&D</b> <config>" , "R&D <config>" ] ,
302+ [ "A B‎‏" , "A\u00a0B\u200e\u200f" ] ,
303+ [ "Keep &unknown;" , "Keep &unknown;" ] ,
304+ ] ) ( "decodes the WebVTT cue payload %j once" , ( payload , text ) => {
305+ const input = `WEBVTT\n\n00:00:01.000 --> 00:00:02.000\n${ payload } \n` ;
306+ expect ( loadTranscript ( tmpFile ( "entities.vtt" , input ) ) . words ) . toEqual ( [
307+ { text, start : 1 , end : 2 , id : "w0" } ,
308+ ] ) ;
309+ } ) ;
310+
284311 it ( "round-trips SRT cues through normalized words" , ( ) => {
285312 const srt = `1
28631300:00:01,000 --> 00:00:03,500
0 commit comments