CTeX-org / ctex-kit

Macro Packages and Scripts for Chinese TeX users
972 stars 124 forks source link

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

Open blefloch opened 3 years ago

blefloch commented 3 years ago

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 commented 3 years ago

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.

qinglee commented 3 years ago

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).