% -*- coding: utf-8 -*- \documentclass{article} \usepackage[b5paper]{geometry} \usepackage{pifont,xcolor,etoolbox} %\usepackage[check-declarations,log-functions]{expl3} \usepackage{expl3,xparse} \ExplSyntaxOn \newcommand{\patchsuccess}[1]{\typeout{Patching~of~\string#1~succeeded.}} \newcommand{\patchfailure}[1]{\typeout{Patching~of~\string#1~failed!}} \ifx \chk_if_free_cs:N \undefined \apptocmd{\__chk_if_free_cs:N} { \iow_log:x { Defining\c_space_tl\token_to_str:N #1\c_space_tl\msg_line_context: } } { \patchsuccess{\__chk_if_free_cs:N}} { \patchfailure{\__chk_if_free_cs:N} } \else \apptocmd{\chk_if_free_cs:N} { \iow_log:x { Defining\c_space_tl\token_to_str:N #1\c_space_tl\msg_line_context: } } { \patchsuccess{\chk_if_free_cs:N}} { \patchfailure{\chk_if_free_cs:N} } \fi %\show\chk_if_free_cs:N \ExplSyntaxOff \usepackage{interchar} \setlength{\parskip}{2pt plus 1pt} \setlength{\parindent}{0pt} \pagestyle{empty} \newcommand{\unspace}{\unskip\unskip\unskip\unskip\unskip\unskip} \newcommand{\passed}{\unspace\hspace{6pt}\textcolor{teal}{\ding{51}}} \newcommand{\failed}{\unspace\hspace{6pt}\textcolor{purple}{\ding{55}}} \begin{document} %\ExplSyntaxOn %\char_set_catcode_space:n {`\ } \catcode `\_ = 11 \catcode `\: = 11 \cs_generate_variant:Nn \tl_if_eq:nnTF {V,x} Testing \verb-\__interchar_class_compare_char:nn- \cs_new_eq:NN \comparechar \__interchar_class_compare_char:nn \tl_set:Nx\l_tmpa_tl{\comparechar{2}{A},\comparechar{10}{A},\comparechar{12}{A}.% \comparechar{40}{2A-2F},\comparechar{45}{2A-2F},\comparechar{50}{2A-2F}.} \tl_if_eq:xnTF {\tl_to_str:N \l_tmpa_tl} {-1,0,1.-1,0,1.} {\passed}{\failed} Testing \verb-\__interchar_class_split_range:nNN- \__interchar_class_split_range:nNN {1234-ABCD} \l_tmpa_tl \l_tmpb_tl \tl_if_eq:VnTF \l_tmpb_tl {ABCD} {\passed}{\failed} \__interchar_class_split_range:nNN {ABCD} \l_tmpa_tl \l_tmpb_tl \tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl {\passed}{\failed} \__interchar_class_split_range:nNN {"AC-"BD} \l_tmpa_tl \l_tmpb_tl \tl_if_eq:VnTF \l_tmpb_tl {"BD} {\passed}{\failed} \__interchar_class_split_range:nNN {"AC} \l_tmpa_tl \l_tmpb_tl \tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl {\passed}{\failed} \__interchar_class_split_range:nNN {`\A} \l_tmpa_tl \l_tmpb_tl \tl_if_eq:VnTF \l_tmpb_tl {`\A} {\passed}{\failed} The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. \vspace{1em} Testing \verb-\newintercharscheme{foo}- \newintercharscheme{foo} \cs_if_exist:cTF {l_interchar_foo_chars_3_clist} {\passed}{\failed} Testing \verb-\newintercharclass[foo]{#2}- \newintercharclass[foo]{\myclassU} \newintercharclass[foo]{\myclassV} \clist_if_in:NnTF \g_interchar_foo_classes_clist {4} {\passed}{\failed} %\intercharclass{"1234}{1} %\intercharclass{"FF45}{2} %\intercharclass{"4567}{3} % `\A `\F `\K `\P `\U `\Z `\a `\f `\k `\p `\u `\z % "41 "46 "4B "50 "55 "5A "61 "66 "6B "70 "75 "7A % 65 70 75 80 85 90 97 102 107 112 117 122 % '101 '106 '113 '120 '125 '132 '141 '146 '153 '160 '165 '172 Testing \verb-\intercharclass[foo]{#2}{#3}- \intercharclass[foo]{"4B}{9} \cs_if_exist:cTF {l_interchar_foo_chars_9_clist} {\passed}{\failed} \intercharclass[foo]{"4B}{0} \clist_if_empty:cTF {l_interchar_foo_chars_9_clist} {\passed}{\failed} \intercharclass[foo]{"5A}{1} \intercharclass[foo]{"5A}{2} \clist_if_in:cnTF {l_interchar_foo_chars_2_clist} {5A} {\passed}{\failed} \intercharclass[foo]{"5A}{3} \clist_if_empty:cTF {l_interchar_foo_chars_2_clist} {\passed}{\failed} \intercharclass[foo]{"44-"47}{3} \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {44-47} {\passed}{\failed} \intercharclass[foo]{"50-"53}{3} \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {50-53} {\passed}{\failed} \intercharclass[foo]{"48-"51}{2} \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {52-53} {\passed}{\failed} \intercharclass[foo]{"45}{2} \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {46-47} {\passed}{\failed} Testing \verb-\getintercharclass[foo]{#2}{#3}- \cs_new_eq:NN \getclass \interchar_get_class:nn \tl_set:Nx \l_tmpa_tl {\getclass{default}{"5555}\getclass{default}{"300A}\getclass{default}{"3001}} \tl_if_eq:xnTF {\tl_to_str:N \l_tmpa_tl} {123} {\passed}{\failed} \getintercharclass{"3456}{\l_tmpa_tl} \tl_if_eq:VnTF \l_tmpa_tl {1} {\passed}{\failed} Testing \verb-\interchartoks[foo]{#2}{#3}{#4}- \newintercharclass[foo]{\myclassW} \intercharclass[foo]{`\o}{\myclassW} \interchartoks[foo]{0}{\myclassW}{\bgroup\color{blue}} \interchartoks[foo]{255}{\myclassW}{\bgroup\color{blue}} \interchartoks[foo]{\myclassW}{0}{\egroup} \interchartoks[foo]{\myclassW}{255}{\egroup} \prop_get:NnN \l_interchar_foo_toks_prop {255 6} \l_tmpa_tl \tl_if_eq:VnTF \l_tmpa_tl {\bgroup\color{blue}} {\passed}{\failed} \XeTeXinterchartokenstate = 0 Testing \verb-\getinterchartoks[foo]{#2}{#3}{#4}- \interchartoks[foo]{\myclassW}{1}{u} \tl_set:Nx \l_tmpa_tl {\interchar_get_toks:nVn{foo}{\myclassW}{1}} \tl_if_eq:VnTF \l_tmpa_tl {u} {\passed}{\failed} \XeTeXinterchartokenstate = 0 Testing \verb-\intercharstate[foo]{#2}-: \intercharstate[foo]{0} \tl_if_eq:VnTF {\XeTeXcharclass `\o} {0} {\passed}{\failed} \tl_if_eq:VnTF {\XeTeXinterchartoks 0 1} {\xtxHanSpace} {\passed}{\failed} \XeTeXinterchartokenstate = 1 Testing \verb-\getintercharstate[foo]{#2}-: \getintercharstate[foo]{\l_tmpa_tl} \tl_if_eq:VnTF \l_tmpa_tl {0} {\passed}{\failed} \intercharstate[foo]{2} \tl_set:Nx \l_tmpa_tl {\interchar_get_state:n{foo}} \tl_if_eq:xnTF {\tl_to_str:N \l_tmpa_tl} {1} {\passed}{\failed} The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. \vspace{1em} \XeTeXinterchartokenstate = 0 Testing \verb-\NewFooIntercharClass #1- \NewFooIntercharClass \myclassQ \clist_if_in:NnTF \g_interchar_foo_classes_clist {7} {\passed}{\failed} Testing \verb-\FooIntercharClass #1 = #2- \FooIntercharClass `\c = \myclassU \FooIntercharClass `\b = \myclassU \FooIntercharClass `\a = \myclassU \clist_if_in:cnTF {l_interchar_foo_chars_4_clist} {61-63} {\passed}{\failed} \FooIntercharClass `\y \myclassV \FooIntercharClass `\z \myclassV \clist_if_in:cnTF {l_interchar_foo_chars_5_clist} {79-7A} {\passed}{\failed} \FooIntercharClass "43 9 \FooIntercharClass "45 9 \FooIntercharClass "44 9 \clist_if_in:cnTF {l_interchar_foo_chars_9_clist} {43-45} {\passed}{\failed} \FooIntercharClass `\L 9 \FooIntercharClass `\M 9 \FooIntercharClass `\O 9 \FooIntercharClass `\N 9 \clist_if_in:cnTF {l_interchar_foo_chars_9_clist} {4C-4F} {\passed}{\failed} \FooIntercharClass `\N 0 \clist_if_in:cnTF {l_interchar_foo_chars_9_clist} {4C-4D} {\passed}{\failed} \FooIntercharClass `\L 0 \FooIntercharClass `\M 0 \FooIntercharClass `\N 0 \FooIntercharClass `\O 0 \FooIntercharClass `\E 0 \FooIntercharClass `\C 0 \FooIntercharClass `\D 0 \clist_if_empty:cTF {l_interchar_foo_chars_9_clist} {\passed}{\failed} Testing \verb-\FooIntercharToks #1 #2 = {#3}- \FooIntercharToks \myclassU \myclassV = {\textcolor{red}{zzz}} \prop_get:NnN \l_interchar_foo_toks_prop {4 5} \l_tmpa_tl \tl_if_eq:VnTF \l_tmpa_tl {\textcolor{red}{zzz}} {\passed}{\failed} Testing \verb-\FooIntercharState = #1- \FooIntercharClass `\o = \myclassV \FooIntercharState = 1 %aa\the\XeTeXinterchartoks 4 5 bb \tl_if_eq:VnTF {\XeTeXcharclass `\o} {5} {\passed}{\failed} \tl_if_eq:VnTF {\XeTeXinterchartoks 4 5} {\textcolor{red}{zzz}} {\passed}{\failed} \FooIntercharState = 2 Testing \verb-\GetFooIntercharState-: \ifnum \GetFooIntercharState = 1 \passed \else \failed \fi \XeTeXinterchartokenstate = 0 Testing \verb-\BarIntercharState = #1-: \XeTeXinterchartokenstate = 1 \newintercharscheme{bar} \NewBarIntercharClass \myclassX \BarIntercharClass `\f \myclassX \BarIntercharClass `\x \myclassX \NewBarIntercharClass \myclassY \BarIntercharClass `\d \myclassY \BarIntercharClass `\g \myclassY \BarIntercharClass `\. \myclassY \BarIntercharToks 255 \myclassX = {\bgroup\color{orange}} \BarIntercharToks \myclassX 255 = {\egroup} \BarIntercharToks 255 \myclassY = {\bgroup\color{olive}} \BarIntercharToks \myclassY 255 = {\egroup} \tl_if_eq:xnTF \l_interchar_current_scheme_tl {foo} {\passed}{\failed} \BarIntercharState = 1 \tl_if_eq:VnTF \l_interchar_current_scheme_tl {bar} {\passed}{\failed} \tl_if_eq:VnTF {\XeTeXcharclass `\d} {5} {\passed}{\failed} \tl_if_eq:VnTF {\XeTeXinterchartoks 255 4} {\bgroup\color{orange}} {\passed}{\failed} The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. \BarIntercharState = 1 \FooIntercharState = 1 The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. % ------------------------------------------------------------------------------ %\clist_show:c {l_interchar_default_chars_1_clist} %\clist_show:c {l_interchar_default_chars_2_clist} %\clist_show:c {l_interchar_default_chars_3_clist} %\clist_show:c {l_interchar_foo_chars_4_clist} %\clist_show:c {l_interchar_foo_chars_5_clist} %\prop_show:N \l_interchar_foo_toks_prop %\prop_show:N \l_interchar_bar_toks_prop \catcode `\_ = 8 \catcode `\: = 12 %\char_set_catcode_ignore:n {`\ }% %\ExplSyntaxOff \end{document}