ctex-kit icon indicating copy to clipboard operation
ctex-kit copied to clipboard

Use catcode table (cctab) instead of \l__kernel_expl_bool in \ctex_push_file:

Open blefloch opened this issue 4 years ago • 2 comments

Currently, \ctex_push_file: and \ctex_pop_file: (used before/after loading a file) check the LaTeX3 internal boolean \l__kernel_expl_bool to determine whether to issue \ExplSyntaxOn or \ExplSyntaxOff after loading the file. I think that the definitions could be replaced by the following code, but I am not totally sure.

\cs_new_protected:Npn \ctex_push_file:
  {
    \cctab_begin:N \c_document_cctab
    \char_set_catcode_letter:n { 64 }
  }
\cs_new_protected:Npn \ctex_pop_file: { \cctab_end: }

blefloch avatar May 13 '21 23:05 blefloch

A similar comment holds in xunicode-addon.sty, which if I understand correctly is also supported by this organization on Github. Let me know if I should open a separate issue.

blefloch avatar May 13 '21 23:05 blefloch

Indeedly, cctab is more elegant. I used it in https://github.com/CTeX-org/ctex-kit/commit/bd9cc7ddd1c2baac288e7763976b11bec113a079 last year. But I found that cctab is not fully compatible with the current LaTeX package loading mechanism (see #544 ). So I reverted to the traditional method in https://github.com/CTeX-org/ctex-kit/commit/182cb98e3df373d3e7035aadf4a365d4c39b8bf7.

\l__kernel_expl_bool is used in \@pushfilename and \@popfilename to track the status of code syntax. When \ExplSyntaxOn is used in the input file which is wrapped by cctab, \ExplSyntaxOff should be manually placed at the end of that file. Otherwise it will cause confusion (see #544).

qinglee avatar Jun 04 '21 10:06 qinglee