@@ -104,6 +104,10 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
104104 s. special_chars [ b'~' as usize ] = true ;
105105 s. skip_chars [ b'~' as usize ] = true ;
106106 }
107+ if options. extension . highlight {
108+ s. special_chars [ b'=' as usize ] = true ;
109+ s. skip_chars [ b'=' as usize ] = true ;
110+ }
107111 if options. extension . superscript || options. extension . inline_footnotes {
108112 s. special_chars [ b'^' as usize ] = true ;
109113 }
@@ -190,6 +194,7 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
190194 '\0' => return false ,
191195 '\r' | '\n' => Some ( self . handle_newline ( ) ) ,
192196 '`' => Some ( self . handle_backticks ( & ast. line_offsets ) ) ,
197+ '=' if self . options . extension . highlight => Some ( self . handle_delim ( b'=' ) ) ,
193198 '\\' => Some ( self . handle_backslash ( ) ) ,
194199 '&' => Some ( self . handle_entity ( ) ) ,
195200 '<' => Some ( self . handle_pointy_brace ( & ast. line_offsets ) ) ,
@@ -635,15 +640,18 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
635640 self . pos - 1 ,
636641 ) ;
637642
638- let is_valid_strikethrough_delim = if c == b'~' && self . options . extension . strikethrough {
643+ let is_valid_double_delim_if_required = if ( c == b'~'
644+ && self . options . extension . strikethrough )
645+ || ( c == b'=' && self . options . extension . highlight )
646+ {
639647 numdelims <= 2
640648 } else {
641649 true
642650 } ;
643651
644652 if ( can_open || can_close)
645653 && ( !( c == b'\'' || c == b'"' ) || self . options . parse . smart )
646- && is_valid_strikethrough_delim
654+ && is_valid_double_delim_if_required
647655 {
648656 self . push_delimiter ( c, can_open, can_close, inl) ;
649657 }
@@ -1116,7 +1124,7 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
11161124 // This array is an important optimization that prevents searching down
11171125 // the stack for openers we've previously searched for and know don't
11181126 // exist, preventing exponential blowup on pathological cases.
1119- let mut openers_bottom: [ usize ; 12 ] = [ stack_bottom; 12 ] ;
1127+ let mut openers_bottom: [ usize ; 13 ] = [ stack_bottom; 13 ] ;
11201128
11211129 // This is traversing the stack from the top to the bottom, setting `closer` to
11221130 // the delimiter directly above `stack_bottom`. In the case where we are processing
@@ -1146,7 +1154,8 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
11461154 b'"' => 3 ,
11471155 b'\'' => 4 ,
11481156 b'_' => 5 ,
1149- b'*' => 6 + ( if c. can_open { 3 } else { 0 } ) + ( c. length % 3 ) ,
1157+ b'*' => 7 + ( if c. can_open { 3 } else { 0 } ) + ( c. length % 3 ) ,
1158+ b'=' => 12 ,
11501159 _ => unreachable ! ( ) ,
11511160 } ;
11521161
@@ -1197,6 +1206,7 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
11971206 && c. delim_char == b'~' )
11981207 || ( self . options . extension . superscript && c. delim_char == b'^' )
11991208 || ( self . options . extension . spoiler && c. delim_char == b'|' )
1209+ || ( self . options . extension . highlight && c. delim_char == b'=' )
12001210 {
12011211 if opener_found {
12021212 // Finally, here's the happy case where the delimiters
@@ -1373,6 +1383,17 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
13731383 } else {
13741384 NodeValue :: EscapedTag ( "~~" . to_owned ( ) )
13751385 }
1386+ } else if opener_char == b'=' {
1387+ // Not emphasis
1388+ // Unlike for |, these cases have to be handled because they will match
1389+ // in the event subscript but not strikethrough is enabled
1390+ if self . options . extension . highlight {
1391+ NodeValue :: Highlight
1392+ } else if use_delims == 1 {
1393+ NodeValue :: EscapedTag ( "=" . to_owned ( ) )
1394+ } else {
1395+ NodeValue :: EscapedTag ( "==" . to_owned ( ) )
1396+ }
13761397 } else if self . options . extension . superscript && opener_char == b'^' {
13771398 NodeValue :: Superscript
13781399 } else if self . options . extension . spoiler && opener_char == b'|' {
0 commit comments