@@ -425,3 +425,91 @@ fn inline_override_unknown_global_warns() {
425425 "expected 'Unknown global option' warning for top-level key, got:\n stderr: {stderr}"
426426 ) ;
427427}
428+
429+ /// Issue #841: MD022 accepts a six-entry array, so validation must not infer the
430+ /// scalar default's integer type as the only valid representation.
431+ #[ test]
432+ fn md022_per_level_inline_override_is_accepted_and_applied ( ) {
433+ let dir = tempdir ( ) . unwrap ( ) ;
434+ fs:: write ( dir. path ( ) . join ( "a.md" ) , "# Title\n \n ## Section\n \n Body.\n " ) . unwrap ( ) ;
435+
436+ let output = Command :: new ( rumdl_bin ( ) )
437+ . current_dir ( dir. path ( ) )
438+ . args ( [
439+ "check" ,
440+ "--no-config" ,
441+ "--no-cache" ,
442+ "--deny-config-warnings" ,
443+ "--config" ,
444+ "MD022.lines-above=[1,3,1,1,1,1]" ,
445+ "a.md" ,
446+ ] )
447+ . output ( )
448+ . unwrap ( ) ;
449+
450+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
451+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
452+ assert_eq ! (
453+ output. status. code( ) ,
454+ Some ( 1 ) ,
455+ "the valid config should run and report the MD022 finding, not fail validation:\n stdout: {stdout}\n stderr: {stderr}"
456+ ) ;
457+ assert ! (
458+ stdout. contains( "[MD022] Expected 3 blank lines above heading" ) ,
459+ "the h2-specific value should be applied:\n stdout: {stdout}\n stderr: {stderr}"
460+ ) ;
461+ assert ! (
462+ !stderr. contains( "[config warning]" ) ,
463+ "a documented MD022 array must not produce a config warning:\n {stderr}"
464+ ) ;
465+ }
466+
467+ /// The file-backed form follows the same validation path and supports `-1` in
468+ /// either per-level array, as documented by MD022.
469+ #[ test]
470+ fn md022_per_level_config_file_is_accepted_and_applied ( ) {
471+ let dir = tempdir ( ) . unwrap ( ) ;
472+ fs:: write (
473+ dir. path ( ) . join ( "custom.toml" ) ,
474+ "[MD022]\n lines-above = [-1, 3, 1, 1, 1, 1]\n lines-below = [1, 1, 3, 1, 1, 1]\n " ,
475+ )
476+ . unwrap ( ) ;
477+ fs:: write (
478+ dir. path ( ) . join ( "a.md" ) ,
479+ "# Title\n \n ## Section\n \n ### Subsection\n \n Body.\n " ,
480+ )
481+ . unwrap ( ) ;
482+
483+ let output = Command :: new ( rumdl_bin ( ) )
484+ . current_dir ( dir. path ( ) )
485+ . args ( [
486+ "check" ,
487+ "--no-cache" ,
488+ "--deny-config-warnings" ,
489+ "--config" ,
490+ "custom.toml" ,
491+ "a.md" ,
492+ ] )
493+ . output ( )
494+ . unwrap ( ) ;
495+
496+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
497+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
498+ assert_eq ! (
499+ output. status. code( ) ,
500+ Some ( 1 ) ,
501+ "the valid config should run and report findings, not fail validation:\n stdout: {stdout}\n stderr: {stderr}"
502+ ) ;
503+ assert ! (
504+ stdout. contains( "[MD022] Expected 3 blank lines above heading" ) ,
505+ "the h2-specific lines-above value should be applied:\n {stdout}"
506+ ) ;
507+ assert ! (
508+ stdout. contains( "[MD022] Expected 3 blank lines below heading" ) ,
509+ "the h3-specific lines-below value should be applied:\n {stdout}"
510+ ) ;
511+ assert ! (
512+ !stderr. contains( "[config warning]" ) ,
513+ "documented MD022 arrays must not produce config warnings:\n {stderr}"
514+ ) ;
515+ }
0 commit comments