diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/knowledge')
-rw-r--r-- | Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx | 88 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx | 55 |
2 files changed, 91 insertions, 52 deletions
diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx index b05e9b8cdf8..1828e3d2aa6 100644 --- a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx +++ b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx @@ -23,7 +23,7 @@ % % \iffalse %<head>\usepackage{expl3} -%<head>\ProvidesExplPackage{knowledge}{2018/02/17}{1.10}{} +%<head>\ProvidesExplPackage{knowledge}{2018/05/17}{1.11}{} %<*driver> \def\knowledgecode{active} \input{knowledge.tex} @@ -42,7 +42,8 @@ % \changes{1.07}{2017/10/15}{minor improvements} % % \changes{1.08}{2017/10/17}{minor changes and reorganization of the files} % % \changes{1.09}{2017/10/31}{minor changes} % -% \changes{1.10}{2018/17/02}{bug fixes} % +% \changes{1.10}{2018/02/17}{bug fixes} % +% \changes{1.11}{2018/05/17}{bug fixes} % % \GetFileInfo{knowledge.sty} % % \DoNotIndex{} % @@ -62,8 +63,8 @@ This directory contains the package name: knowledge license: LaTeX Project Public License version 1.2 or above - version: v1.10 - date: 2018/02/17 + version: v1.11 + date: 2018/05/17 author: Thomas Colcombet mail: thomas.colcombet@irif.fr web: https://www.irif.fr/~colcombe/knowledge_en.html @@ -244,6 +245,7 @@ Content of the file knowledge-sources.zip: {Some~knowledge~is~used~but~not~introduced.~See~the~'.diagnose'~file~for~more~information.} % \end{macrocode} % +% % \subsection{Option and packages} % % @@ -1050,6 +1052,7 @@ Content of the file knowledge-sources.zip: % \end{macrocode} % \begin{macrocode} \cs_new:Nn\scope_internal_push:n { + \ScopeActivate \tl_gset:Nn\scope_top_area_tl{#1} \int_gincr:c{\scope_tl.area[\scope_top_area_tl].nesting_int} \int_gincr:c{\scope_tl.area[\scope_top_area_tl].count_int} @@ -1301,15 +1304,15 @@ Content of the file knowledge-sources.zip: % like knowledge. % \begin{macrocode} \NewDocumentCommand\ScopeActivate{}{ - \scope_internal_push:n{base} \cs_gset_eq:NN\ScopeActivate\relax + \scope_internal_push:n{base} } \AtBeginDocument{\ScopeActivate} % \end{macrocode} % % \begin{macrocode} \AtBeginDocument{\ScopeHackEnvironments} -%\AtEndDocument{\scope_area_pop:n{document}} +\AtEndDocument{\scope_area_pop:n{document}} % \end{macrocode} % % \begin{macrocode} @@ -1335,7 +1338,7 @@ Content of the file knowledge-sources.zip: {body}{knowledge=none} % \newenvironment{scope} - {\mode_if_preamble:TF{\scope_area_push:n{scope}}{}} + {\mode_if_preamble:TF{\ScopeActivate\scope_area_push:n{scope}}{}} {\mode_if_preamble:TF{\scope_area_pop:n{scope}}{}} \knowledgeconfigureenvironment{scope}{} % \end{macrocode} @@ -2069,11 +2072,12 @@ Content of the file knowledge-sources.zip: % % % The \cs{\kl}, and its internal version \cs{\klTKS} are the central ones in the package. Indeed, all commands such as \cs{\intro}, \cs{\phantomintro}, \cs{\reintro} or the \kl{"...@...@..."} notation eventually end to a call to these functions. -% -% Essentially, \cs{\kl} parses its parameters, and then call its internal version \cs{\knowledge_klTKS:nnn} +%\AP Essentially, \cs{\kl} parses its parameters, and then call its internal version \cs{\knowledge_klTKS:nnn} % with proper parameters: Text, Knowledge, Scope (the scope can be empty): +% +% \AP The macro \csintro{\knowledge_kl:w} is the part of \cs{\kl}-like commands that parses the arguments, and then calls \cs{\knowledge_klTKS:nnn} with proper arguments. % \begin{macrocode} -\NewDocumentCommand\__kl:w{d() o d() m}{ +\NewDocumentCommand\knowledge_kl:w{d() o d() m}{ \IfNoValueTF{#1} {\IfNoValueTF{#3} {\IfNoValueTF{#2} @@ -2088,11 +2092,13 @@ Content of the file knowledge-sources.zip: } % \end{macrocode} % -% The following macro, \cs{\knowledge_klTKS:nnn} is the internal version of \cs{\kl}. it takes explicitely the text to be displayed, +% \AP The following macro, \csintro{\knowledge_klTKS:nnn} is an internal version of \cs{\kl}-like commands. it takes explicitely the text to be displayed, % followed by the \kl{knowledge name} to be used, and a \kl{label} pointing to the \kl[instance]{instance of scope} -% in which the \kl{knowledge name} has to searched. This \kl{label} can be empty, and in this case, this means that +% in which the \kl{knowledge name} has to be searched for. This \kl{label} can be empty, and in this case, this means that % the stack of instances that are visible in the context of the call of the command should be inspected for searching for -% the knowledge. There exists a version \cs{\klTKS} which can be used, and does not require the \kl(package){expl3} syntax. +% the knowledge. +% \AP The macro \csintro{\klTKS} is a version of \cs{\knowledge_klTKS:nnn} +% that can be used without the "expl3@@package" syntax. % \begin{macrocode} \tl_clear_new:N\knowledge_kl_text_tl \tl_clear_new:N\knowledge_kl_base_key_tl @@ -2148,10 +2154,10 @@ Content of the file knowledge-sources.zip: % and then launches the search. % % -% The core of the \cs{\kl} command is \csintro{\knowledge_kl_find:}. +%\AP The core of the \cs{\kl} command is \csintro{\knowledge_kl_find:}. % It uses the variables \cs{\knowledge_kl_recursion_int} for checking non-recursion. % It searches for the entry \cs{\knowledge_kl_key_tl}, either in searching in the \kl{stack of visible scope instances}, -% or following \cs{\knowledge_kl_linkscope_tl} if the label exist. +% or following \cs{\knowledge_kl_linkscope_tl} if the label exists. % It first works on whether a scope label is given or not: % \begin{macrocode} \cs_set:Nn\knowledge_kl_find:{ @@ -2505,7 +2511,7 @@ Content of the file knowledge-sources.zip: % \NewDocumentCommand#1{s} {\knowledge_kl_modifiers_add:N#1 - \IfBooleanF{##1}{\__kl:w}} + \IfBooleanF{##1}{\knowledge_kl:w}} % \tl_new_eq:cN {knowledge_kl_\cs_to_str:N#1_namespace_tl} @@ -2614,25 +2620,25 @@ Content of the file knowledge-sources.zip: % When defining a new use of \texttt{knowledge}, many macros have to be taken into account. % Some have to be defined explicitly. Some other have default behaviours. % \begin{asparaitem} -% \item \csintro{\knowledge_kl_display_preprocess_tl} is the code to be used first before displaying. It does nothing for \cs{\kl}, but is set to \cs{\knowledge_kl_target_preprocess_tl} for \cs{\intro}, which performs the \cs{\label} command fir the introduction. -% \item \csintro{\knowledge_kl_display_process_tl} is the code to be executed for displaying the \kl{knowledge}. This is not defined by default. -% \item \csintro{\knowledge_kl_error_unknown:} The fallback code to execute when the \kl{knowledge} is unknown. +% \itemAP \csintro{\knowledge_kl_display_preprocess_tl} is the code to be used first before displaying. It does nothing for \cs{\kl}, but is set to \cs{\knowledge_kl_target_preprocess_tl} for \cs{\intro}, which performs the \cs{\label} command fir the introduction. +% \itemAP \csintro{\knowledge_kl_display_process_tl} is the code to be executed for displaying the \kl{knowledge}. This is not defined by default. +% \itemAP \csintro{\knowledge_kl_error_unknown:} The fallback code to execute when the \kl{knowledge} is unknown. % By default, it displays a warning and put the name in orange. -% \item \csintro{\knowledge_kl_update:N} is a code to be executed to update the knowledge. By default, it increments the ktuple counter `\cs{countuse_int}'. -% \item \csintro{\knowledge_kl_namespace_tl} is the \kl{namespace} in which the \kl{knowledge} is to be searched. Not defined by default. -% \item \csintro{\knowledge_kl_linkscope_tl} is a label that points to an instance of a \kl{scope}. It can be empty, and in this case, this means that the search proceeds in the \kl{stack of visible scope instances}. By default it is empty. -% \item \csintro{\knowledge_kl_max_recursion_int} is the maximum number of recursion allowed when searching for a \kl{knowledge}. It is by default 40. +% \itemAP \csintro{\knowledge_kl_update:N} is a code to be executed to update the knowledge. By default, it increments the ktuple counter `\cs{countuse_int}'. +% \itemAP \csintro{\knowledge_kl_namespace_tl} is the \kl{namespace} in which the \kl{knowledge} is to be searched. Not defined by default. +% \itemAP \csintro{\knowledge_kl_linkscope_tl} is a label that points to an instance of a \kl{scope}. It can be empty, and in this case, this means that the search proceeds in the \kl{stack of visible scope instances}. By default it is empty. +% \itemAP \csintro{\knowledge_kl_max_recursion_int} is the maximum number of recursion allowed when searching for a \kl{knowledge}. It is by default 40. % \end{asparaitem} % % The codes can uses internally the following variables, that are accessible for the user when defining new \cs\kl-like commands: % \begin{asparaitem} -% \item \csintro{\knowledge_kl_command_tl} the command that has triggered the search -% \item \csintro{\knowledge_kl_base_key_tl} contains the name of the knowledge for which the search has started, -% \item \csintro{\knowledge_kl_text_tl} contains the text to be displayed, -% \item \csintro{\knowledge_kl_key_tl} contains the name of the knowledge searched at a particular moment, -% \item \csintro{\knowledge_kl_recursion_int} counts the number of indirection in the current, starting from \cs{\knowledge_kl_max_recursion_int}, and going down, -% \item \csintro{\knowledge_kl_link_tl} contains the link to be followed. -% \item \cs{\knowledge_kl_resourcetoken_tl} contains a single token, which is the location of the knowledge. +% \itemAP \csintro{\knowledge_kl_command_tl} the command that has triggered the search +% \itemAP \csintro{\knowledge_kl_base_key_tl} contains the name of the knowledge for which the search has started, +% \itemAP \csintro{\knowledge_kl_text_tl} contains the text to be displayed, +% \itemAP \csintro{\knowledge_kl_key_tl} contains the name of the knowledge searched at a particular moment, +% \itemAP \csintro{\knowledge_kl_recursion_int} counts the number of indirection in the current, starting from \cs{\knowledge_kl_max_recursion_int}, and going down, +% \itemAP \csintro{\knowledge_kl_link_tl} contains the link to be followed. +% \itemAP \cs{\knowledge_kl_resourcetoken_tl} contains a single token, which is the location of the knowledge. % \end{asparaitem} % % \begin{macrocode} @@ -2960,11 +2966,11 @@ Content of the file knowledge-sources.zip: {\int_compare:nNnTF\l_tmpa_int=1 {} {\int_to_alph:n\l_tmpa_int}} \exp_args:Nx\label{\exp_not:V\knowledge_kl_autoref_tl\l_tmpa_tl}} - \expandafter\ktuple_countintro_gincr:N - \knowledge_kl_resourcetoken_tl - \KAuxWriteX - {\exp_not:N\KAuxAutorefTarget - \exp_not:o\knowledge_kl_resourcearguments_tl}} + \expandafter\ktuple_countintro_gincr:N + \knowledge_kl_resourcetoken_tl + \KAuxWriteX + {\exp_not:N\KAuxAutorefTarget + \exp_not:o\knowledge_kl_resourcearguments_tl}} } \cs_new:Nn\knowledge_kl_compute_code_makeidx:{ \tl_if_exist_ne:NTF\knowledge_kl_index_tl @@ -3472,15 +3478,15 @@ Content of the file knowledge-sources.zip: \knowledgenewvariant\kl{ - namespace=default, - default style={kl,autoref link}, + namespace= default, + default style= {kl,autoref link}, unknown style= kl unknown, - unknown style cont=kl unknown cont, + unknown style cont= kl unknown cont, style directive={style} } \knowledgenewvariant\intro{ - namespace=default, - default style={intro,autoref target}, + namespace= default, + default style= {intro,autoref target}, unknown style= intro unknown, unknown style cont= intro unknown cont, style directive= intro style @@ -3634,7 +3640,7 @@ Content of the file knowledge-sources.zip: \exp_args:NNV\ExplSyntaxOff\knowledgeconfigure\knowledge_configuration_pending_tl % \end{macrocode} % \begin{macrocode} -\ScopeActivate +%\ScopeActivate % \end{macrocode} %</tail> % diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx index 961ebf925b6..9e8ede9bd8b 100644 --- a/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx +++ b/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx @@ -102,6 +102,13 @@ {} {\tl_set_eq:Nc\c_sys_jobname_str{c_job_name_tl}} % \end{macrocode} +% The interface of expl3 since Mars 2018 has changed and a small patch is required: +% \begin{macrocode} +%\tl_if_exist:NTF +% \ior_str_get:NN +% {} +% {\tl_set_eq:NN\ior_str_get:NN\ior_get_str:NN} +% \end{macrocode} % Some useful adding (newset). % \begin{macrocode} \cs_new:Nn\tl_new:Nn @@ -976,7 +983,7 @@ \bool_do_until:Nn\l_tmpa_bool{ \ior_if_eof:NTF\klg_tmpa_ior {\bool_set_true:N\l_tmpa_bool} - {\ior_get_str:NN + {\ior_str_get:NN \klg_tmpa_ior \l_tmpa_tl \exp_args:NNV @@ -1011,10 +1018,10 @@ {\ior_if_eof:NTF\klg_tmpb_ior {\bool_set_true:N\l_tmpa_bool \bool_set_false:N\l_tmp_bool} - {\ior_get_str:NN + {\ior_str_get:NN \klg_tmpa_ior \l_tmpa_tl - \ior_get_str:NN + \ior_str_get:NN \klg_tmpb_ior \l_tmpb_tl \tl_if_eq:NNF @@ -1064,17 +1071,43 @@ % % \subsubsection{Overloading command} % Overloading a command is similar in syntax to |\NewDocumentCommand| -% of the \texttt{xparse} package, but it further offer the macro |\SUPERcommand| +% of the \texttt{xparse} package, but it further offers the macro |\SUPERcommand| % (where |\command| is the token under definition), which can be used for calling the original code. -% It is often used in combination with |\XparseArgs| for recreating the arguments if necesssary. -% -% +% Formally, the syntax is:\\ +% |\OverloadCommand\command{arguments}[variant name]{code}|\\ +% The arguments follox the \texttt{xparse} syntax. The variant name is by default ``\texttt{NEW}''. +% Other variants of the commands can be defined by changing this text. +% The macro |\ChooseCommand| allows to choose between the variant. It takes as first argument a control sequence (or a chain of control sequences), and as second argument the variant that should be taken. +% Hence |\ChooseCommand\command{SUPER}| reverts |\command| to its original behaviour. % \begin{macrocode} +\cs_new:Npn\commandVariant#1#2{#2\cs_to_str:N#1} + \cs_generate_variant:Nn\cs_gset_eq:NN{cN,cc} -\NewDocumentCommand\OverloadCommand{mmm} - {\exp_args:Nc\cs_gset_eq:NN{SUPER\cs_to_str:N#1}#1 - \exp_args:Nc\NewDocumentCommand{NEW\cs_to_str:N#1}{#2}{#3} - \cs_gset_eq:Nc#1{NEW\cs_to_str:N#1}} +\NewDocumentCommand\OverloadCommand{mmO{NEW}m} + {\cs_if_exist:cTF + {\commandVariant#1{switch~}} + {} + {\exp_args:Nc\cs_gset_eq:NN + {\commandVariant#1{SUPER}} + #1 + \exp_args:NNx\cs_gset:Npn + #1{\exp_not:c{\commandVariant#1{switch~}}} + } + \exp_args:Nc\NewDocumentCommand + {\commandVariant#1{#3}}{#2}{#4} + \ChooseCommand#1{#3} +} +\NewDocumentCommand\ChooseCommand{mm}{ + \tl_map_inline:nn{#1} + {\cs_if_exist:cTF + {\commandVariant##1{#2}} + {\cs_gset_eq:cc + {\commandVariant##1{switch~}} + {\commandVariant##1{#2}}} + {\tl_show:n + {knowledge_utils~ERROR:~##1~has~no~variant~{#2}}} + } +} % \end{macrocode} % % |