Skip to content

Commit 8d3528d

Browse files
authored
Merge pull request #14 from Sophanatprime/main
reimplement \fakeverb with \tl_analysis_map_inline:Nn
2 parents 16c4ae7 + 1d95f9c commit 8d3528d

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

codehigh.sty

+14-23
Original file line numberDiff line numberDiff line change
@@ -603,36 +603,27 @@
603603
%%> \section{Fake Verbatim Command}
604604
%%% -------------------------------------------------------
605605
606-
\tl_new:N \l__codehigh_fake_code_tl
606+
\tl_const:Nn \c__codehigh_fake_escape_tl { \\\{\}\#\^\ \% }
607607
608608
\NewDocumentCommand \fakeverb { +m }
609609
{
610610
\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:
613624
\group_end:
614625
}
615626
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-
636627
%%% -------------------------------------------------------
637628
%%> \section{Tracing CodeHigh}
638629
%%% -------------------------------------------------------

0 commit comments

Comments
 (0)