@@ -3822,7 +3822,20 @@ peg::parser! {
38223822 content: $( (
38233823 "\\ " "^" !( [ ^'^' | ' ' | '\t' | '\n' ] + "^" )
38243824 / "\\ " "~" !( [ ^'~' | ' ' | '\t' | '\n' ] + "~" )
3825- / ( !( eol( ) * <2 , > / ![ _] / escaped_syntax_match( ) / bold_text_unconstrained( start_pos, block_metadata) / bold_text_constrained_match( ) / italic_text_unconstrained( start_pos, block_metadata) / italic_text_constrained_match( ) / monospace_text_unconstrained( start_pos, block_metadata) / monospace_text_constrained_match( ) / highlight_text_unconstrained( start_pos, block_metadata) / highlight_text_constrained_match( ) / superscript_text( start_pos, block_metadata) / subscript_text( start_pos, block_metadata) / curved_quotation_text( start_pos, block_metadata) / curved_apostrophe_text( start_pos, block_metadata) / standalone_curved_apostrophe( start_pos, block_metadata) ) [ _] )
3825+ // Fast path: characters that can never start any quotes inline construct.
3826+ // Fewer triggers than plain_text since quotes context has no macros/autolinks.
3827+ / [ ^( '\n' | '\r' | '\\' | '[' | '*' | '_' | '`' | '#' | '^' | '~' | '"' | '\'' ) ] +
3828+ / (
3829+ !(
3830+ eol( ) * <2 , >
3831+ / ![ _]
3832+ / & [ '\\' ] escaped_syntax_match( )
3833+ / & [ '*' | '_' | '`' | '#' | '^' | '~' | '"' | '\'' | '[' ] (
3834+ bold_text_unconstrained( start_pos, block_metadata) / bold_text_constrained_match( ) / italic_text_unconstrained( start_pos, block_metadata) / italic_text_constrained_match( ) / monospace_text_unconstrained( start_pos, block_metadata) / monospace_text_constrained_match( ) / highlight_text_unconstrained( start_pos, block_metadata) / highlight_text_constrained_match( ) / superscript_text( start_pos, block_metadata) / subscript_text( start_pos, block_metadata) / curved_quotation_text( start_pos, block_metadata) / curved_apostrophe_text( start_pos, block_metadata) / standalone_curved_apostrophe( start_pos, block_metadata)
3835+ )
3836+ )
3837+ [ _]
3838+ )
38263839 ) +)
38273840 end: position!( )
38283841 {
@@ -5171,7 +5184,27 @@ peg::parser! {
51715184 // a complete pattern (those are handled by escaped_superscript_subscript rule)
51725185 "\\ " "^" !( [ ^'^' | ' ' | '\t' | '\n' ] + "^" )
51735186 / "\\ " "~" !( [ ^'~' | ' ' | '\t' | '\n' ] + "~" )
5174- / ( !( eol( ) * <2 , > / ![ _] / escaped_syntax_match( ) / hard_wrap( offset) / ( check_macros( block_metadata) ( inline_anchor_match( ) / index_term_match( ) / cross_reference_shorthand_match( ) / cross_reference_macro_match( ) / footnote_match( offset, block_metadata) / inline_image( start_pos, block_metadata) / inline_icon( start_pos, block_metadata) / inline_stem( start_pos) / inline_keyboard( start_pos) / inline_button( start_pos) / inline_menu( start_pos) / mailto_macro( start_pos, block_metadata) / url_macro( start_pos, block_metadata) / inline_pass( start_pos) / link_macro( start_pos) ) ) / ( check_macros( block_metadata) check_autolinks( allow_autolinks) inline_autolink( start_pos) ) / inline_line_break( start_pos) / bold_text_unconstrained( start_pos, block_metadata) / bold_text_constrained_match( ) / italic_text_unconstrained( start_pos, block_metadata) / italic_text_constrained_match( ) / monospace_text_unconstrained( start_pos, block_metadata) / monospace_text_constrained_match( ) / highlight_text_unconstrained( start_pos, block_metadata) / highlight_text_constrained_match( ) / superscript_text( start_pos, block_metadata) / subscript_text( start_pos, block_metadata) / curved_quotation_text( start_pos, block_metadata) / curved_apostrophe_text( start_pos, block_metadata) / standalone_curved_apostrophe( start_pos, block_metadata) ) [ _] )
5187+ // Fast path: characters that can never start any inline construct.
5188+ // Conservative set — excludes all alphanumerics (bare email autolinks can start
5189+ // with any letter/digit), formatting markers, escape chars, and construct openers.
5190+ // Safe: tab, common punctuation like , ; . ? ! : - / > ) ] } | @ & = {
5191+ / [ '\t' | ',' | ';' | '.' | '?' | '!' | ':' | '/' | '>' | ')' | ']' | '}' | '|' | '@' | '&' | '=' | '{' | '\u{00A0}' ..='\u{10FFFF}' ] +
5192+ // Slow path: potential construct trigger character. Use character-class guards to
5193+ // skip groups of rules whose starting character doesn't match.
5194+ / (
5195+ !(
5196+ eol( ) * <2 , >
5197+ / ![ _]
5198+ / & [ '\\' ] escaped_syntax_match( )
5199+ / & [ ' ' ] ( hard_wrap( offset) / inline_line_break( start_pos) )
5200+ // Macro guard: [ ( < for delimiters, then first letters of each macro:
5201+ // a=asciimath, b=btn, f=footnote/ftp, h=http(s), i=image/icon/indexterm/irc,
5202+ // k=kbd, l=link/latexmath, m=menu/mailto, p=pass, s=stem, x=xref
5203+ / ( check_macros( block_metadata) & [ '[' | '(' | '<' | 'a' | 'b' | 'f' | 'h' | 'i' | 'k' | 'l' | 'm' | 'p' | 's' | 'x' ] ( inline_anchor_match( ) / index_term_match( ) / cross_reference_shorthand_match( ) / cross_reference_macro_match( ) / footnote_match( offset, block_metadata) / inline_image( start_pos, block_metadata) / inline_icon( start_pos, block_metadata) / inline_stem( start_pos) / inline_keyboard( start_pos) / inline_button( start_pos) / inline_menu( start_pos) / mailto_macro( start_pos, block_metadata) / url_macro( start_pos, block_metadata) / inline_pass( start_pos) / link_macro( start_pos) ) )
5204+ / ( check_macros( block_metadata) check_autolinks( allow_autolinks) inline_autolink( start_pos) )
5205+ / & [ '*' | '_' | '`' | '#' | '^' | '~' | '"' | '\'' | '[' ] ( bold_text_unconstrained( start_pos, block_metadata) / bold_text_constrained_match( ) / italic_text_unconstrained( start_pos, block_metadata) / italic_text_constrained_match( ) / monospace_text_unconstrained( start_pos, block_metadata) / monospace_text_constrained_match( ) / highlight_text_unconstrained( start_pos, block_metadata) / highlight_text_constrained_match( ) / superscript_text( start_pos, block_metadata) / subscript_text( start_pos, block_metadata) / curved_quotation_text( start_pos, block_metadata) / curved_apostrophe_text( start_pos, block_metadata) / standalone_curved_apostrophe( start_pos, block_metadata) )
5206+ ) [ _]
5207+ )
51755208 ) +)
51765209 end: position!( )
51775210 {
0 commit comments