@@ -344,6 +344,52 @@ test('small caps runs can be configured with style mapping', function() {
344
344
} ) ;
345
345
346
346
347
+ test ( 'highlighted runs are ignored by default' , function ( ) {
348
+ var run = runOfText ( "Hello." , { highlight : "yellow" } ) ;
349
+ var converter = new DocumentConverter ( ) ;
350
+ return converter . convertToHtml ( run ) . then ( function ( result ) {
351
+ assert . equal ( result . value , "Hello." ) ;
352
+ } ) ;
353
+ } ) ;
354
+
355
+ test ( 'highlighted runs can be configured with style mapping for all highlights' , function ( ) {
356
+ var run = runOfText ( "Hello." , { highlight : "yellow" } ) ;
357
+ var converter = new DocumentConverter ( {
358
+ styleMap : [
359
+ {
360
+ from : documentMatchers . highlight ( null ) ,
361
+ to : htmlPaths . elements ( [ htmlPaths . element ( "mark" ) ] )
362
+ }
363
+ ]
364
+ } ) ;
365
+ return converter . convertToHtml ( run ) . then ( function ( result ) {
366
+ assert . equal ( result . value , "<mark>Hello.</mark>" ) ;
367
+ } ) ;
368
+ } ) ;
369
+
370
+ test ( 'highlighted runs can be configured with style mapping for specific highlight color' , function ( ) {
371
+ var paragraph = new documents . Paragraph ( [
372
+ runOfText ( "Yellow" , { highlight : "yellow" } ) ,
373
+ runOfText ( "Red" , { highlight : "red" } )
374
+ ] ) ;
375
+ var converter = new DocumentConverter ( {
376
+ styleMap : [
377
+ {
378
+ from : documentMatchers . highlight ( { color : "yellow" } ) ,
379
+ to : htmlPaths . elements ( [ htmlPaths . element ( "mark" , { "class" : "yellow" } ) ] )
380
+ } ,
381
+ {
382
+ from : documentMatchers . highlight ( { color : undefined } ) ,
383
+ to : htmlPaths . elements ( [ htmlPaths . element ( "mark" ) ] )
384
+ }
385
+ ]
386
+ } ) ;
387
+ return converter . convertToHtml ( paragraph ) . then ( function ( result ) {
388
+ assert . equal ( result . value , '<p><mark class="yellow">Yellow</mark><mark>Red</mark></p>' ) ;
389
+ } ) ;
390
+ } ) ;
391
+
392
+
347
393
test ( 'run styles are converted to HTML if mapping exists' , function ( ) {
348
394
var run = runOfText ( "Hello." , { styleId : "Heading1Char" , styleName : "Heading 1 Char" } ) ;
349
395
var converter = new DocumentConverter ( {
0 commit comments