|
603 | 603 | %%> \section{Fake Verbatim Command}
|
604 | 604 | %%% -------------------------------------------------------
|
605 | 605 |
|
606 |
| -\tl_new:N \l__codehigh_fake_code_tl |
| 606 | +\tl_const:Nn \c__codehigh_fake_escape_tl { \\\{\}\#\^\ \% } |
607 | 607 |
|
608 | 608 | \NewDocumentCommand \fakeverb { +m }
|
609 | 609 | {
|
610 | 610 | \group_begin:
|
611 |
| - \tl_set:Nn \l__codehigh_fake_code_tl {#1} |
612 |
| - \__codehigh_fake_verb:N \l__codehigh_fake_code_tl |
| 611 | + \group_align_safe_begin: |
| 612 | + \ttfamily \frenchspacing |
| 613 | + \tl_analysis_map_inline:nn {#1} |
| 614 | + { |
| 615 | + \int_compare:nNnTF {##2} = { -1 } |
| 616 | + { |
| 617 | + \exp_args:NNo \tl_if_in:NnTF \c__codehigh_fake_escape_tl {##1} |
| 618 | + { \exp_after:wN \cs_to_str:N ##1 } |
| 619 | + { \exp_after:wN \token_to_str:N ##1 } |
| 620 | + } |
| 621 | + { \exp_after:wN \token_to_str:N ##1 } |
| 622 | + } |
| 623 | + \group_align_safe_end: |
613 | 624 | \group_end:
|
614 | 625 | }
|
615 | 626 |
|
616 |
| -\cs_new_protected:Npn \__codehigh_fake_verb:N #1 |
617 |
| - { |
618 |
| - \regex_replace_all:nnN { \c{\\} } { \\ } #1 |
619 |
| - % use \cO to avoid errors of unmatched braces |
620 |
| - \regex_replace_all:nnN { \c{\{} } { \cO\{ } #1 |
621 |
| - \regex_replace_all:nnN { \c{\}} } { \cO\} } #1 |
622 |
| - % use \cO to avoid doubled hash characters |
623 |
| - \regex_replace_all:nnN { \c{\#} } { \cO\# } #1 |
624 |
| - % need to escape ^ because ^^ and ^^^^ are special |
625 |
| - \regex_replace_all:nnN { \c{\^} } { \^ } #1 |
626 |
| - % why we can not use \c{\ } instead of \c{\h}? |
627 |
| - \regex_replace_all:nnN { \c{\h} } { \ } #1 |
628 |
| - \regex_replace_all:nnN { \c{\%} } { \% } #1 |
629 |
| - % remove spaces after control words |
630 |
| - \regex_replace_all:nnN { . } { \c{string}\0 } #1 |
631 |
| - \tl_set:Ne #1 { #1 } |
632 |
| - %\tl_log:N #1 |
633 |
| - \ttfamily \frenchspacing \tl_to_str:N #1 |
634 |
| - } |
635 |
| -
|
636 | 627 | %%% -------------------------------------------------------
|
637 | 628 | %%> \section{Tracing CodeHigh}
|
638 | 629 | %%% -------------------------------------------------------
|
|
0 commit comments