@@ -459,4 +459,98 @@ class RenderContentCompilerTests: XCTestCase {
459
459
XCTAssertEqual ( codeListing. syntax, " swift " )
460
460
XCTAssertEqual ( codeListing. highlight, [ 1 , 2 , 3 ] )
461
461
}
462
+
463
+ func testMultipleHighlightMultipleStrikeout( ) async throws {
464
+ enableFeatureFlag ( \. isExperimentalCodeBlockEnabled)
465
+
466
+ let ( bundle, context) = try await testBundleAndContext ( )
467
+ var compiler = RenderContentCompiler ( context: context, bundle: bundle, identifier: ResolvedTopicReference ( bundleID: bundle. id, path: " /path " , fragment: nil , sourceLanguage: . swift) )
468
+
469
+ let source = #"""
470
+ ```swift, strikeout=[3,5], highlight=[1, 2, 3]
471
+ let a = 1
472
+ let b = 2
473
+ let c = 3
474
+ let d = 4
475
+ let e = 5
476
+ ```
477
+ """#
478
+
479
+ let document = Document ( parsing: source)
480
+
481
+ let result = document. children. flatMap { compiler. visit ( $0) }
482
+
483
+ let renderCodeBlock = try XCTUnwrap ( result [ 0 ] as? RenderBlockContent )
484
+ guard case let . codeListing( codeListing) = renderCodeBlock else {
485
+ XCTFail ( " Expected RenderBlockContent.codeListing " )
486
+ return
487
+ }
488
+
489
+ XCTAssertEqual ( codeListing. syntax, " swift " )
490
+ XCTAssertEqual ( codeListing. highlight, [ 1 , 2 , 3 ] )
491
+ XCTAssertEqual ( codeListing. strikeout, [ 3 , 5 ] )
492
+ }
493
+
494
+ func testLanguageNotFirstOption( ) async throws {
495
+ enableFeatureFlag ( \. isExperimentalCodeBlockEnabled)
496
+
497
+ let ( bundle, context) = try await testBundleAndContext ( )
498
+ var compiler = RenderContentCompiler ( context: context, bundle: bundle, identifier: ResolvedTopicReference ( bundleID: bundle. id, path: " /path " , fragment: nil , sourceLanguage: . swift) )
499
+
500
+ let source = #"""
501
+ ```highlight=[1, 2, 3], swift, wrap=20, strikeout=[3]
502
+ let a = 1
503
+ let b = 2
504
+ let c = 3
505
+ let d = 4
506
+ let e = 5
507
+ ```
508
+ """#
509
+
510
+ let document = Document ( parsing: source)
511
+
512
+ let result = document. children. flatMap { compiler. visit ( $0) }
513
+
514
+ let renderCodeBlock = try XCTUnwrap ( result [ 0 ] as? RenderBlockContent )
515
+ guard case let . codeListing( codeListing) = renderCodeBlock else {
516
+ XCTFail ( " Expected RenderBlockContent.codeListing " )
517
+ return
518
+ }
519
+
520
+ XCTAssertEqual ( codeListing. highlight, [ 1 , 2 , 3 ] )
521
+ // we expect the language to be the first option in the language line, otherwise it remains nil.
522
+ XCTAssertEqual ( codeListing. syntax, nil )
523
+ XCTAssertEqual ( codeListing. wrap, 20 )
524
+ XCTAssertEqual ( codeListing. strikeout, [ 3 ] )
525
+ }
526
+
527
+ func testUnorderedArrayOptions( ) async throws {
528
+ enableFeatureFlag ( \. isExperimentalCodeBlockEnabled)
529
+
530
+ let ( bundle, context) = try await testBundleAndContext ( )
531
+ var compiler = RenderContentCompiler ( context: context, bundle: bundle, identifier: ResolvedTopicReference ( bundleID: bundle. id, path: " /path " , fragment: nil , sourceLanguage: . swift) )
532
+
533
+ let source = #"""
534
+ ```highlight=[5,3,4], strikeout=[3,1]
535
+ let a = 1
536
+ let b = 2
537
+ let c = 3
538
+ let d = 4
539
+ let e = 5
540
+ ```
541
+ """#
542
+
543
+ let document = Document ( parsing: source)
544
+
545
+ let result = document. children. flatMap { compiler. visit ( $0) }
546
+
547
+ let renderCodeBlock = try XCTUnwrap ( result [ 0 ] as? RenderBlockContent )
548
+ guard case let . codeListing( codeListing) = renderCodeBlock else {
549
+ XCTFail ( " Expected RenderBlockContent.codeListing " )
550
+ return
551
+ }
552
+
553
+ XCTAssertEqual ( codeListing. highlight, [ 5 , 3 , 4 ] )
554
+ XCTAssertEqual ( codeListing. strikeout, [ 3 , 1 ] )
555
+ }
462
556
}
0 commit comments