lvjr / codehigh

Highlight codes and demos with l3regex and lpeg
https://ctan.org/pkg/codehigh
11 stars 6 forks source link

Make \fakeverb run faster #13

Closed lvjr closed 6 months ago

lvjr commented 6 months ago

We may make \fakeverb run faster by not using l3regex:

Another implement would be to use \tl_analysis_map_inline:n, which is pretty fast:

\tl_const:Nn \c__cus_verbatimize_macros_tl { \#\%\\\ \{\}\^ }
\NewDocumentCommand \FakeVerb { m }
  {
    \group_begin:
    \ttfamily \frenchspacing
    \tl_analysis_map_inline:nn {#1}
      { 
        \int_compare:nNnTF {##2} = { -\c_one_int }
          {
            \exp_args:NNo \tl_if_in:NnTF \c__cus_verbatimize_macros_tl {##1} 
                { \exp_after:wN \cs_to_str:N ##1 } { \exp_after:wN \token_to_str:N ##1 }
          }
          { \exp_after:wN \token_to_str:N ##1 }
      }
    \group_end:
  }

Originally posted by @Sophanatprime in lvjr/tabularray#370 (reply in thread)

lvjr commented 6 months ago

@Sophanatprime Are you interested in making a pull request for this improvement?