summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/passopt/passopt.sty
blob: b5c24ed9a30fca350d8bea05afbad4e8e65665f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%
% ***************** THE PASSOPT PACKAGE *****************
%
% Copyright (C) 2024 by Qu Yi <toquyi@163.com>
%
% This work may be distributed and/or modified under the
% conditions of the CC-BY 4.0 License.
% The latest version of this license is in
%   https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}[2021/11/15]
\ProvidesExplPackage{passopt}{2024/07/15}{1.01}
  {Passing options to packages or classes}

\cs_generate_variant:Nn \tl_if_blank:nTF { v }
\cs_new_protected:Npn \po_add_before_hook:nnn #1#2
  { \hook_gput_code:nnn { #1/#2/before } { passopt } }
\cs_new_protected:Npn \po_set_options_list:nnnnn #1#2#3#4#5
  {
    \po_add_before_hook:nnn {#1} {#5}
      {
        \cs_set:cpx { @raw@opt@#5.#2 }
          {
            \IfBooleanTF{#3}
              {\exp_not:o {#4}}
              {
                \tl_if_blank:vTF { @raw@opt@#5.#2 }
                  { \exp_not:o {#4} }
                  { \exp_not:v { @raw@opt@#5.#2 },\exp_not:o {#4} }
              }
          }
        \exp_args:Nc \protected@edef { opt@#5.#2 }
          {
            \exp_last_unbraced:Nv
              \zap@space { @raw@opt@#5.#2 }~\@empty
          }
      }
  }
\cs_new_protected:Npn \po_clear_options_list:nnn #1#2#3
  {
    \po_add_before_hook:nnn {#1} {#3}
      {
        \tl_clear:c { @raw@opt@#3.#2 }
        \tl_clear:c { opt@#3.#2 }
      }
  }
\NewDocumentCommand{\SetOptionsToPackage}{smm}
  {\po_set_options_list:nnnnn { package } { sty } {#1} {#2} {#3}}
\NewDocumentCommand{\SetOptionsToClass}{smm}
  {\po_set_options_list:nnnnn { class } { cls } {#1} {#2} {#3}}
\cs_new_protected:Npn \ClearPackageOptions #1
  { \po_clear_options_list:nnn { package } { sty } {#1} }
\cs_new_protected:Npn \ClearClassOptions #1
  { \po_clear_options_list:nnn { class } { cls } {#1} }
\endinput
%
% End of file `passopt.sty'.