@@ -518,7 +518,7 @@ impl<'i> Parser<'i> {
518518 // different natural number here.
519519 fn read_magic_line ( & mut self ) -> Result < u8 , ParsingError < ' i > > {
520520 self . take_until ( & [ '\n' ] , |inner| {
521- let re = regex ! ( r"%\s*technique\s+v1" ) ;
521+ let re = regex ! ( r"%\s*technique\s+v1\s*$ " ) ;
522522
523523 if re. is_match ( inner. source ) {
524524 Ok ( 1 )
@@ -2112,6 +2112,14 @@ fn analyze_magic_line(content: &str) -> usize {
21122112 return 0 ;
21132113 }
21142114
2115+ // If both "technique" and "v1" are present but still invalid (like "v1.0"),
2116+ // point to the character immediately after "v1"
2117+ if trimmed. contains ( "technique" ) && trimmed. contains ( "v1" ) {
2118+ if let Some ( v1_pos) = content. find ( "v1" ) {
2119+ return v1_pos + 2 ; // Position after "v1"
2120+ }
2121+ }
2122+
21152123 // Point to where version should be if missing v1
21162124 if !trimmed. contains ( "v1" ) {
21172125 // Find position after "technique"
@@ -2465,6 +2473,7 @@ mod check {
24652473
24662474 // Test edge case where there's no "v" at all - should point to where version should start
24672475 assert_eq ! ( analyze_magic_line( "% technique 1.0" ) , 12 ) ; // Points to "1" when there's no "v"
2476+ assert_eq ! ( analyze_magic_line( "% technique v1.0" ) , 14 ) ; // Points to "." when there is a "v1" but it has minor version
24682477 assert_eq ! ( analyze_magic_line( "% technique 2" ) , 13 ) ; // Points to "2" when there's no "v" with extra space
24692478 assert_eq ! ( analyze_magic_line( "% technique beta" ) , 12 ) ; // Points to "b" in "beta" when there's no "v"
24702479 }
0 commit comments