@@ -1652,24 +1652,18 @@ impl<'a, 'o, 'c> Parser<'a, 'o, 'c> {
16521652 }
16531653
16541654 fn process_tasklist ( & mut self , node : & ' a AstNode < ' a > , text : & mut Vec < u8 > ) {
1655- let relaxed_tasklist_matching = self . options . parse . relaxed_tasklist_matching ;
16561655 static TASKLIST : OnceCell < Regex > = OnceCell :: new ( ) ;
1657- let r = TASKLIST . get_or_init ( || {
1658- if relaxed_tasklist_matching {
1659- Regex :: new ( r"\A(\s*\[(.)\])(?:\z|\s)" ) . unwrap ( )
1660- } else {
1661- Regex :: new ( r"\A(\s*\[([xX\s])\])(?:\z|\s)" ) . unwrap ( )
1662- }
1663- } ) ;
1656+ let r = TASKLIST . get_or_init ( || Regex :: new ( r"\A(\s*\[(.)\])(?:\z|\s)" ) . unwrap ( ) ) ;
16641657
16651658 let ( symbol, end) = match r. captures ( text) {
16661659 None => return ,
1667- Some ( c) => (
1668- c. get ( 2 ) . unwrap ( ) . as_bytes ( ) . to_owned ( ) ,
1669- c. get ( 0 ) . unwrap ( ) . end ( ) ,
1670- ) ,
1660+ Some ( c) => ( c. get ( 2 ) . unwrap ( ) . as_bytes ( ) [ 0 ] , c. get ( 0 ) . unwrap ( ) . end ( ) ) ,
16711661 } ;
16721662
1663+ if !self . options . parse . relaxed_tasklist_matching && !matches ! ( symbol, b' ' | b'x' | b'X' ) {
1664+ return ;
1665+ }
1666+
16731667 let parent = node. parent ( ) . unwrap ( ) ;
16741668 if node. previous_sibling ( ) . is_some ( ) || parent. previous_sibling ( ) . is_some ( ) {
16751669 return ;
@@ -1689,8 +1683,8 @@ impl<'a, 'o, 'c> Parser<'a, 'o, 'c> {
16891683 let checkbox = inlines:: make_inline (
16901684 self . arena ,
16911685 NodeValue :: TaskItem {
1692- checked : symbol != b" " ,
1693- symbol : symbol[ 0 ] ,
1686+ checked : symbol != b' ' ,
1687+ symbol : symbol,
16941688 } ,
16951689 ) ;
16961690 node. insert_before ( checkbox) ;
0 commit comments