diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/ctex/ctexhook.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/ctex/ctexhook.sty | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/latex/ctex/ctexhook.sty b/Master/texmf-dist/tex/latex/ctex/ctexhook.sty index e6478dc9378..ee858d5c9de 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexhook.sty +++ b/Master/texmf-dist/tex/latex/ctex/ctexhook.sty @@ -6,9 +6,9 @@ %% %% ctex.dtx (with options: `ctexhook') %% -%% Copyright (C) 2003--2019 +%% Copyright (C) 2003--2020 %% CTEX.ORG and any individual authors listed in the documentation. -%% ------------------------------------------------------------------------------ +%% --------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either @@ -20,25 +20,23 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -%% This work has the LPPL maintenance status `maintained'. +%% This work has the LPPL maintenance status "maintained". %% -%% The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. -%% -%% ------------------------------------------------------------------------------ +%% --------------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee@gmail.com> $ {Document and package hooks (CTEX)} \ProvidesExplPackage{ctexhook} - {\ExplFileDate}{2.4.16}{\ExplFileDescription} -\cs_new_protected:Npn \ctex_at_end_preamble:n #1 - { \tl_gput_right:Nn \g__ctex_end_preamble_hook_tl {#1} } -\cs_new_protected:Npn \ctex_after_end_preamble:n #1 - { \tl_gput_right:Nn \g__ctex_after_end_preamble_hook_tl {#1} } -\cs_new_protected_nopar:Npn \CTEX@document@left@hook + {\ExplFileDate}{2.5.1}{\ExplFileDescription} +\cs_new_protected:Npn \ctex_at_end_preamble:n + { \tl_gput_right:Nn \g__ctex_end_preamble_hook_tl } +\cs_new_protected:Npn \ctex_after_end_preamble:n + { \tl_gput_right:Nn \g__ctex_after_end_preamble_hook_tl } +\cs_new_protected:Npn \CTEX@document@left@hook { \group_end: \g__ctex_end_preamble_hook_tl \group_begin: } -\cs_new_protected_nopar:Npn \CTEX@document@right@hook +\cs_new_protected:Npn \CTEX@document@right@hook { \scan_stop: \g__ctex_after_end_preamble_hook_tl \tex_ignorespaces:D } \cs_set_nopar:Npx \document { @@ -48,28 +46,51 @@ } \tl_new:N \g__ctex_end_preamble_hook_tl \tl_new:N \g__ctex_after_end_preamble_hook_tl -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 +\cs_new_protected:Npn \ctex_at_begin_package:nn #1 { \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } + { \__ctex_package_loaded_warning:nn {#1} } + { \ctex_gadd_package_hook:nnn { begin } {#1} } + } +\cs_new_protected:Npn \__ctex_package_loaded_warning:nn #1#2 + { \msg_warning:nnx { ctex } { invalid-hook } {#1} } +\msg_new:nnn { ctex } { invalid-hook } + { + Package~`#1'~is~loaded. \\ + \token_to_str:N \ctex_at_begin_package:nn \{#1\}\{...\}~is~invalid. } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 +\cs_new_protected:Npn \ctex_at_end_package:nn #1 + { + \@ifpackageloaded {#1} + { \use:n } + { \ctex_gadd_package_hook:nnn { end } {#1} } + } +\cs_new_protected:Npn \ctex_gadd_package_hook:nnn #1#2 + { \ctex_gadd_hook:cn { g__ctex_at_ #1 _ #2 _hook_tl } } +\cs_new_protected:Npn \ctex_gadd_hook:Nn #1 { \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} + \tl_gput_right:Nn #1 } \cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 +\cs_new_protected:Npn \ctex_use_package_hook:nn #1#2 + { + \group_begin: \exp_args:NNc \group_end: + \__ctex_use_package_hook_aux:N { g__ctex_at_ #1 _ #2 _hook_tl } + } +\cs_new_protected:Npn \__ctex_use_package_hook_aux:N #1 + { \cs_if_exist_use:NT #1 { \cs_undefine:N #1 } } +\tl_put_right:Nn \@reset@ptions { \CTEX@reset@ptions@hook } +\cs_new_protected:Npn \CTEX@reset@ptions@hook { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } + \cs_if_eq:NNT \@currext \@pkgextension + { \ctex_use_package_hook:nn { begin } { \@currname } } } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename +\tl_put_left:Nn \@popfilename { \CTEX@popfilename@hook } +\cs_new_protected:Npn \CTEX@popfilename@hook { \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } + { \ctex_use_package_hook:nn { end } { \@currname } } } %% %% |