@@ -1032,7 +1032,7 @@ impl<'a, 'b> FirstPass<'a, 'b> {
10321032 LoopInstruction :: ContinueAndSkip ( 1 )
10331033 }
10341034 }
1035- c @ b'*' | c @ b'_' | c @ b'~' | c @ b'^' => {
1035+ c @ b'*' | c @ b'_' | c @ b'~' | c @ b'^' | c @ b'=' => {
10361036 let string_suffix = & self . text [ ix..] ;
10371037 let count = 1 + scan_ch_repeat ( & string_suffix. as_bytes ( ) [ 1 ..] , c) ;
10381038 let can_open = delim_run_can_open (
@@ -1051,7 +1051,11 @@ impl<'a, 'b> FirstPass<'a, 'b> {
10511051 mode,
10521052 self . options ,
10531053 ) ;
1054- let is_valid_seq = ( c != b'~' || count <= 2 ) || ( c == b'~' && count == 2 ) ;
1054+ let is_valid_seq = match c {
1055+ b'~' => count <= 2 ,
1056+ b'=' => count == 2 ,
1057+ _ => true ,
1058+ } ;
10551059
10561060 if ( can_open || can_close) && is_valid_seq {
10571061 self . tree . append_text ( begin_text, ix, backslash_escaped) ;
@@ -2428,6 +2432,9 @@ fn delim_run_can_open(
24282432 if delim == b'~' && run_len > 1 {
24292433 return true ;
24302434 }
2435+ if delim == b'=' && run_len == 2 {
2436+ return true ;
2437+ }
24312438 let prev_char = s[ ..ix] . chars ( ) . last ( ) . unwrap ( ) ;
24322439 if delim == b'~'
24332440 && ( prev_char == '~' || options. contains ( Options :: ENABLE_SUBSCRIPT ) )
@@ -2473,7 +2480,11 @@ fn delim_run_can_close(
24732480 }
24742481 let delim = suffix. bytes ( ) . next ( ) . unwrap ( ) ;
24752482 // `*`, `~~`, and `^` can be intraword, `~` can only be interword if it's subscript, `_` cannot
2476- if ( delim == b'*' || ( delim == b'~' && run_len > 1 ) ) && !is_punctuation ( prev_char) {
2483+ if ( delim == b'*'
2484+ || ( delim == b'~' && run_len > 1 )
2485+ || ( delim == b'=' && run_len == 2 ) )
2486+ && !is_punctuation ( prev_char)
2487+ {
24772488 return true ;
24782489 }
24792490 if delim == b'^' && !is_punctuation ( prev_char) {
@@ -2520,6 +2531,9 @@ fn special_bytes(options: &Options) -> [bool; 256] {
25202531 if options. contains ( Options :: ENABLE_SUPERSCRIPT ) {
25212532 bytes[ b'^' as usize ] = true ;
25222533 }
2534+ if options. contains ( Options :: ENABLE_HIGHLIGHT ) {
2535+ bytes[ b'=' as usize ] = true ;
2536+ }
25232537 if options. contains ( Options :: ENABLE_MATH ) {
25242538 bytes[ b'$' as usize ] = true ;
25252539 bytes[ b'{' as usize ] = true ;
@@ -2551,8 +2565,13 @@ struct LookupTable {
25512565type LookupTable = [ bool ; 256 ] ;
25522566
25532567/// This function walks the byte slices from the given index and
2554- /// calls the callback function on all bytes (and their indices) that are in the following set:
2555- /// `` ` ``, `\`, `&`, `*`, `_`, `~`, `!`, `<`, `[`, `]`, `|`, `\r`, `\n`
2568+ /// calls the callback function on all bytes (and their indices) that are in the
2569+ /// special-bytes set defined by [`special_bytes`]/[`simd::compute_lookup`].
2570+ /// The always-included bytes are
2571+ /// `` ` ``, `\`, `&`, `*`, `_`, `!`, `<`, `[`, `]`, `\r`, `\n`; additional bytes
2572+ /// are added when their corresponding option is enabled (e.g. `|` with tables,
2573+ /// `~` with strikethrough/subscript, `^` with superscript, `=` with highlight,
2574+ /// `$`/`{`/`}` with math, and `.`/`-`/`"`/`'` with smart punctuation).
25562575/// It is guaranteed not call the callback on other bytes.
25572576/// Whenever `callback(ix, byte)` returns a `ContinueAndSkip(n)` value, the callback
25582577/// will not be called with an index that is less than `ix + n + 1`.
@@ -2766,6 +2785,9 @@ mod simd {
27662785 if options. contains ( Options :: ENABLE_SUPERSCRIPT ) {
27672786 add_lookup_byte ( & mut lookup, b'^' ) ;
27682787 }
2788+ if options. contains ( Options :: ENABLE_HIGHLIGHT ) {
2789+ add_lookup_byte ( & mut lookup, b'=' ) ;
2790+ }
27692791 if options. contains ( Options :: ENABLE_MATH ) {
27702792 add_lookup_byte ( & mut lookup, b'$' ) ;
27712793 add_lookup_byte ( & mut lookup, b'{' ) ;
0 commit comments