summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/knowledge/knowledge-code.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-10-04 03:01:00 +0000
committerNorbert Preining <norbert@preining.info>2019-10-04 03:01:00 +0000
commit9d9c04e14d0da9dd7829d0ec896aabfd50414fd8 (patch)
treef67d308a037384664193d9a2cfca27d8b0579701 /macros/latex/contrib/knowledge/knowledge-code.dtx
parent93c3758895674cc9ea3e8aaeeb3cf5d1bdc0e3be (diff)
CTAN sync 201910040301
Diffstat (limited to 'macros/latex/contrib/knowledge/knowledge-code.dtx')
-rw-r--r--macros/latex/contrib/knowledge/knowledge-code.dtx653
1 files changed, 476 insertions, 177 deletions
diff --git a/macros/latex/contrib/knowledge/knowledge-code.dtx b/macros/latex/contrib/knowledge/knowledge-code.dtx
index 22bb364790..6f0c693028 100644
--- a/macros/latex/contrib/knowledge/knowledge-code.dtx
+++ b/macros/latex/contrib/knowledge/knowledge-code.dtx
@@ -23,7 +23,7 @@
%
% \iffalse
%<head>\usepackage{expl3}
-%<head>\ProvidesExplPackage{knowledge}{2019/02/16}{1.16}{}
+%<head>\ProvidesExplPackage{knowledge}{2019/10/03}{1.17}{}
%<*driver>
\def\knowledgecode{active}
\input{knowledge.tex}
@@ -49,6 +49,7 @@
% \changes{1.14}{2018/11/22}{bug fix} %
% \changes{1.15}{2019/01/23}{doc change} %
% \changes{1.16}{2019/02/15}{correct anchor point locations} %
+% \changes{1.17}{2019/10/03}{improvements} %
% \GetFileInfo{knowledge.sty} %
% \DoNotIndex{}
%
@@ -68,8 +69,8 @@ This directory contains the package
name: knowledge
license: LaTeX Project Public License version 1.2 or above
- version: v1.16
- date: 2019/02/15
+ version: v1.17
+ date: 2019/10/03
author: Thomas Colcombet
mail: thomas.colcombet@irif.fr
web: https://www.irif.fr/~colcombe/knowledge_en.html
@@ -117,7 +118,6 @@ Content of the file knowledge-sources.zip:
\RequirePackage{l3keys2e}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
-\RequirePackage{etoolbox}
\bool_if_exist:NTF\knowledge_package_loaded_bool
{\endinput}
{\bool_new:N\knowledge_package_loaded_bool
@@ -163,6 +163,12 @@ Content of the file knowledge-sources.zip:
\cs_generate_variant:Nn\tl_to_str:n{V}
% \end{macrocode}
%
+% \begin{macrocode}
+\tl_new:N\char_escape_tl
+\tl_set:Nx\char_escape_tl
+ {\expandafter\tl_head:n\expandafter{\string\escape}}
+% \end{macrocode}
+%
% \subsection{Messages of the package}
%
%\AP First, some generic messages that are produced using \csintro{\knowledge_info:n},
@@ -219,6 +225,10 @@ Content of the file knowledge-sources.zip:
\msg_new:nnn{ knowledge }{ knowledge~exists }
{ The~knowledge~'#1'~in~scope~'#2'~(namespace~'#3')~already~exists. }
% \end{macrocode}
+% \begin{macrocode}
+\msg_new:nnn{ knowledge }{ knowledgedirective~redifinition }
+ { Directive~'#1'~already~exists~(\knowledgedirective~macro). }
+% \end{macrocode}
%
%\AP The messages when there is a problem with scoping are \csintro{area~exists}, \csintro{area~not~exist},
% \csintro{empty~pop}, \csintro{no~pushing~here}, \csintro{no~popping},
@@ -421,6 +431,12 @@ Content of the file knowledge-sources.zip:
% \end{macrocode}
%
% \begin{macrocode}
+\bool_new:N\knowledge_configuration_barsuggestion_bool
+\bool_gset_false:N\knowledge_configuration_barsuggestion_bool
+\KnowledgeConfigureBooleanOption[\knowledge_configuration_barsuggestion_bool]{bar~suggestion}
+% \end{macrocode}
+%
+% \begin{macrocode}
\bool_new:N\knowledge_configuration_visibleAP_bool
\KnowledgeConfigureBooleanOption[\knowledge_configuration_visibleAP_bool]{visible~anchor~points}\KnowledgeConfigureBooleanOption[\knowledge_configuration_visibleAP_bool]{visible~AP}
% \end{macrocode}
@@ -444,7 +460,12 @@ Content of the file knowledge-sources.zip:
\KnowledgeConfigureTrigger{ fix~hyperref~twocolumn }
{\knowledgeFixHyperrefTwocolumn}
\KnowledgeConfigureTrigger{ notion }
- {\KnowledgeConfigureNotion{notion}}
+ {\KnowledgeConfigureNotion{notion}
+ \knowledgesetvariant\kl{suggestion=notion}
+ \knowledgesetvariant\intro{suggestion=notion}
+ \knowledgesetvariant\phantomintro{suggestion=notion}
+ \knowledgesetvariant\reintro{suggestion=notion}
+ }
\KnowledgeConfigureTrigger{ protect~links }
{\kl_kl_nesting_incr:}
\KnowledgeConfigureTrigger{ unprotect~links }
@@ -626,9 +647,9 @@ Content of the file knowledge-sources.zip:
% \item[\kl{categories}] are collections of \kl{areas} that share some common behaviours, for instance, the \kl{category} `\texttt{itemize-like}' will aggregate
% `\texttt{itemize}', `\texttt{enumerate}' \kl{areas}. In particular an `\texttt{item}'
% \kl{area} is required to have a parent that belongs to the \kl{category} `\texttt{itemize-like}'.
-% \item[\kl{instances}] are the realization of \kl{areas} in a document. Hence `section' is an \kl{area},
+% \item[\intro{instances}] are the realization of \kl{areas} in a document. Hence `section' is an \kl{area},
% but each section of a document is an \kl{instance}.
-% \item[\kl{scopept instances}] stands for `phase two'. These are functions that are activated during
+% \item[\intro{scopept instances}] stands for `phase two'. These are functions that are activated during
% the second compilation. (and also, under implementation, in the preamble)
% \item[\kl{knowledges}] are the central notion
% \end{description}
@@ -964,7 +985,7 @@ Content of the file knowledge-sources.zip:
\seq_gpop:NNTF\scope_instances_stack_seq\l_tmpa_tl
{\tl_gset_eq:NN\scope_top_instance_tl\l_tmpa_tl
\int_gdecr:c{\scope_tl.area[\scope_top_area_tl].nesting_int}
- \exp_args:NV\knowledge_pop_visible_instances_to:n\scope_top_instance_tl
+ \knowledge_pop_visible_instances_to_mark:
\seq_get:NN\scope_instances_stack_seq\l_tmpa_tl
\tl_gset_eq:NN\scope_top_instance_tl\l_tmpa_tl
\tl_gset:Nx\scope_top_area_tl
@@ -1071,6 +1092,7 @@ Content of the file knowledge-sources.zip:
{\scope_top_area_tl-\int_to_arabic:n{\int_use:c{\scope_tl.area[\scope_top_area_tl].count_int}}}}
{\tl_gset_eq:NN\scope_top_instance_tl\scope_top_area_tl}
%
+ \knowledge_push_visible_instance_mark:
\exp_args:Nx\knowledge_push_visible_instance:n{\scope_top_instance_tl}
\seq_gpush:Nx\scope_instances_stack_seq{\scope_top_instance_tl}
%
@@ -1118,8 +1140,6 @@ Content of the file knowledge-sources.zip:
% instance able to receive knowledges.
% This is done by inspecting the scope stack until reaching an instance
% that has \kl{instance.attractsknowledge_bool} set to true (by default, this is `base').
-%
-% Searching for instances.
% \begin{macrocode}
\cs_new:Nn\scope_get_attractive_instance:N
{\tl_set:Nn#1{base}
@@ -1129,9 +1149,11 @@ Content of the file knowledge-sources.zip:
{\tl_set:Nn#1{##1}\seq_map_break:}{}}
}
% \end{macrocode}
-%
+% \csintro{\scope_get_labelizable_instance:N} takes a token list variable as input for holding the result.
+% It inspects the current stack of instances \cs{\scope_instances_stack_seq}, searching for an "instance"
+% of a "scope" which is labelizable, and returns it. The default is `base'.
% \begin{macrocode}
-\cs_new:Nn\scope_get_labelizable_instance:N
+\cs_new:Nn\scope_get_labelizable_instance:N
{\tl_set:Nn#1{base}
\seq_map_inline:Nn\scope_instances_stack_seq
{\bool_if:cTF
@@ -1139,15 +1161,19 @@ Content of the file knowledge-sources.zip:
{\tl_set:Nn#1{##1}\seq_map_break:}{}}
}
% \end{macrocode}
-%
-% The command \cs{\knowledge_scope_track_instance:Nn} tries to find a given instance in the current context,
+% The command \csintro{\knowledge_scope_track_instance:Nn} is the internal part od the "scope=" directive.
+% It takes as argument a token list variable for holding the result, and a text to be looked for.
+% If the text corresponds to a "scope" name (such as section, theorem, \dots), then it inspects the
+% content of the stacks for finding the target.
+% Otherwise, it uses it as a label.
% and if it fails, it tries to find a label of this name that provides an instance.
% \begin{macrocode}
-\cs_new:Nn\knowledge_scope_track_instance:Nn{
- \scope_area_if_exist:nTF{#2}
- {\knowledge_scope_track_instance_from_area:Nn#1{#2}}
- {\knowledge_scope_track_instance_from_label:Nn#1{#2}}
-}
+%\cs_new:Nn\knowledge_scope_track_instance:Nn{
+% \tl_show:n{#1:#2}
+% \scope_area_if_exist:nTF{#2}
+% {\knowledge_scope_track_instance_from_area:Nn#1{#2}}
+% {\knowledge_scope_track_instance_from_scopetag:Nn#1{#2}}
+%}
\cs_new:Nn\knowledge_scope_track_instance_from_area:Nn{
\tl_set:Nn#1{}
\seq_map_inline:Nn\scope_instances_stack_seq
@@ -1160,11 +1186,18 @@ Content of the file knowledge-sources.zip:
{\msg_error:nnxx{scope}{area~not~in~context}{#2}{scope=}}
{}
}
-\cs_new:Nn\knowledge_scope_track_instance_from_label:Nn{
- \tl_set:Nn#1{}
- \scopept_label_instance_if_exist:nTF{#2}
- {\tl_set:Nx#1{\scopept_label_instance_use:n{#2}}}
- {\msg_warning:nnnn{scope}{unknown~label}{#2}{scope=}}
+% \end{macrocode}
+% The command \cs{\knowledge_scope_track_scope:n}
+% is used to set the variable \cs{\knowledge_knowledge_instance_tl}.
+% If the argument is a scope name, then it is searched for in the context, and the corresponding "instance" is used.
+% Otherwise it is used as a "scopetag"; this "scopetag" being potentially
+% defined if necessary using \cs{\knowledge_scopetag_warn_if_unknown:n}.
+% \begin{macrocode}
+\cs_new:Nn\knowledge_scope_track_scope:n{
+ \scope_area_if_exist:nTF{#1}
+ {\knowledge_scope_track_instance_from_area:Nn\knowledge_knowledge_instance_tl{#1}}
+ {\tl_set:Nn\knowledge_knowledge_instance_tl{explicit-scope:#1}
+ \knowledge_scopetag_warn_if_unknown:n{#1}}
}
% \end{macrocode}
% \begin{macrocode}
@@ -1194,31 +1227,114 @@ Content of the file knowledge-sources.zip:
% \end{macrocode}
%
%
-% \subsubsection{Label overloading}
+% \subsubsection{Scope tags}
%
-% In order to identify scopes, the standard \cs{\label} command is used.
-% This requires to overload it for it to write on the \kl{kaux file}.
-% Thus, the new \cs{\label} command executes the original code,
-% and furthermore writes in the \kl{kaux file} a \cs{\KAuxScopeLabel} command.
-% \iffalse
-% Note that in order to accelerate compilation, the label is both written on the "kaux file",
-% and directly in the memory. This
-% \fi
+% A ""scopetag"" is a name that can be used to identify a family of "instances" that correspond to it.
+% It gets to have two variables attached to it:
+% \begin{description}
+% \itemAP[\cs{\knowledge_scopetag_tl}\texttt{{[TAG]}\_bool}] which tells whether it
+% has been officially declared (it is false if it has been used but not declared by a \cs{\knowledgescope}
+% or a \cs{\label} command).
+% \itemAP[\cs{\knowledge_scopetag_tl}\texttt{{[TAG]}\_seq}] is a sequence of
+% "instances" that are attached to it. It always contains (as soon as created)
+% \end{description}
+%
+% In order to identify scopes, the command~\cs{\knowledgescope} (or \cs{\label} which is overloaded for this purpose).
+%
+% \par\noindent\AP\csintro{\knowledge_scopetag_tl} is a unique string for identifying "scopetags".
+% \par\noindent\AP\csintro{\knowledge_scopetag_if_exist:nTF} tests the existence of a "scopetag".
+% \par\noindent\AP\csintro{\knowledge_scopetag_ensure:n} guarantees that the "scopetag" is defined (by default, the boolean is set to false).
+% \par\noindent\AP\csintro{\knowledge_scopetag_warn_if_unknown:n} writes \cs{\KAuxUndeclaredScopeTag} to the "kaux file" if the "scopetag" was never met before, then calls \cs{\knowledge_scopetag_ensure:n}.
+% \par\noindent\AP\csintro{\knowledge_scopetag_declares:n} creates the "scopetag" if necessary, and if it was not known before, declares and puts a \cs{\KAuxDeclaredScopeTag} command in the "kaux file".
+% \begin{macrocode}
+\tl_const:Nn\knowledge_scopetag_tl{ScpT@g}
+% \end{macrocode}
% \begin{macrocode}
-\NewDocumentCommand\scopeLabel{m}
- { \kl_hide_begin:
+\cs_new:Npn\knowledge_scopetag_if_exist:nTF#1
+ {\tl_if_exist:cTF{\knowledge_scopetag_tl[#1]_bool}}
+\cs_new:Nn\knowledge_scopetag_ensure:n{
+ \knowledge_scopetag_if_exist:nTF{#1}{}
+ {\bool_new:c{\knowledge_scopetag_tl[#1]_bool}
+ \bool_gset_false:c{\knowledge_scopetag_tl[#1]_bool}
+ \seq_new:c{\knowledge_scopetag_tl[#1]_seq}
+ \seq_gput_right:cn{\knowledge_scopetag_tl[#1]_seq}{explicit-scope:#1}}}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn\knowledge_scopetag_warn_if_unknown:n{
+ \knowledge_scopetag_if_exist:nTF{#1}{}
+ {\KAuxWriteX*{\exp_not:N\KAuxUndeclaredScopeTag{#1}}
+ \knowledge_scopetag_ensure:n{#1}}
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn\knowledge_scopetag_declares:n{
+ \knowledge_scopetag_ensure:n{#1}
+ \bool_if:cTF{\knowledge_scopetag_tl[#1]_bool}
+ {}
+ {\KAuxWriteX*{\exp_not:N\KAuxDeclaredScopeTag{#1}}
+ \bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}}
+}
+% \end{macrocode}
+% \AP The command \csintro{\knowledgescope} associates an "instance" to one or more "scopetags":
+% \begin{macrocode}
+\NewDocumentCommand\knowledgescope{ >{\SplitList{,}}m }{
+ \kl_hide_begin:\group_begin:
+ \ProcessList{#1}\knowledge_knowledgescope_one:n
+ \group_end:\kl_hide_end:
+}
+\cs_new:Nn\knowledge_knowledgescope_one:n{
+ \knowledge_scopetag_declares:n{#1}
\scope_get_labelizable_instance:N\l_tmpb_tl
- \KAuxWriteX*{\exp_not:n{\KAuxScopeLabel}{\exp_not:n{#1}}{\l_tmpb_tl}}
- %\tl_new:cx{\scopept_tl.label[#1].instance_tl}{\l_tmpb_tl}
- \kl_hide_end:
- \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1}}
+ \KAuxWriteX*{\exp_not:n{\KAuxNewLinkScopetagInstance}{\exp_not:n{#1}}{\l_tmpb_tl}}
+}
+% \end{macrocode}
+%
+% \paragraph{Modified labels}
+% \AP The boolean \csintro{\knowledge_configuration_label_autoscope_bool}
+% activates or deactivates the automatic calling to \cs{knowlegescope} when \cs{\label} is used.
+% \begin{macrocode}
+\bool_new:N\knowledge_configuration_label_autoscope_bool
+\bool_gset_true:N\knowledge_configuration_label_autoscope_bool
% \end{macrocode}
+% \noindent\AP\csintro{\scopeLabel} implicitly adds a call to \cs{\knowledgescope} (if \cs{\knowledge_configuration_label_autoscope_bool} is set to true), and then calls the original \cs{\label} code.
% \begin{macrocode}
+\NewDocumentCommand\scopeLabel{m}{
+ \kl_hide_begin:
+ \bool_if:NT
+ \knowledge_configuration_label_autoscope_bool
+ \knowledge_knowledgescope_one:n{#1}
+ \kl_hide_end:
+ \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1}
+}
\let\label\scopeLabel
+% \end{macrocode}
+% \AP In order to cicumvent this overloading, the normal \cs{\label} command
+% can be used using \csintro{\knowledge_latex_label:n}:
+% \begin{macrocode}
\cs_new:Npn\knowledge_latex_label:n{
\cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\label
}
% \end{macrocode}
+% \par\noindent\csintro{\knowledge_scopetag_warn_if_unknown:n} takes a "scopetag" as input.
+% If it does not exist, it defines, and sets its boolean to false.
+% \begin{macrocode}
+\NewKAuxCommand\KAuxUndeclaredScopeTag{m}
+ {Package~scope:~States~that~a~labelname~is~used~in~a~knowledge~definition.}
+\DeclareKAuxPhaseCommand\KAuxUndeclaredScopeTag{init}{}
+\NewKAuxCommand\KAuxDeclaredScopeTag{m}
+ {Package~scope:~States~that~a~labelname~has~been~declared.}
+\DeclareKAuxPhaseCommand\KAuxDeclaredScopeTag{init}{
+ \knowledge_scopetag_if_exist:nTF{#1}{}
+ {\bool_new:c{\knowledge_scopetag_tl[#1]_bool}}
+ \bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}
+ }
+\NewKAuxCommand\KAuxNewLinkScopetagInstance{mm}
+ {Package~scope:~Declares~that~a~label~is~declared~in~an~instance~of~a~scope.}
+\DeclareKAuxPhaseCommand\KAuxNewLinkScopetagInstance{init}{
+ \knowledge_scopetag_ensure:n{#1}
+ \seq_gput_right:cn{\knowledge_scopetag_tl[#1]_seq}{#2}
+}
+% \end{macrocode}
%
%
%\subsubsection{Processing the \kl{kaux file}}
@@ -1234,9 +1350,9 @@ Content of the file knowledge-sources.zip:
\tl_new:cn{\scopept_tl.instance[#2].parent_tl}{#3}}
% \end{macrocode}
% \begin{macrocode}
-\NewKAuxCommand\KAuxScopeLabel{mm}
- {Package~scope:~Links~a~label~to~the~scope~of~its~definition.}
-\DeclareKAuxPhaseCommand\KAuxScopeLabel{init}
+\NewKAuxCommand\KAuxScopeTag{mm}
+ {Package~scope:~Links~a~scopetag~to~an~instance~of~a~scope.}
+\DeclareKAuxPhaseCommand\KAuxScopeTag{init}
{\tl_if_exist:cTF{\scopept_tl.label[\tl_to_str:n{#1}].instance_tl}{}
{\tl_new:cn{\scopept_tl.label[\tl_to_str:n{#1}].instance_tl}{#2}}}
% \end{macrocode}
@@ -1511,9 +1627,9 @@ Content of the file knowledge-sources.zip:
% We define now the basic macros that are used for accessing knowledges.
% Each knowledge is identified by three parameters:
% \begin{itemize}
-% \item the namespace name (no arobas in it), each different use of the "knowledge@@package" package can use a different namespace. For the moment, this is always `default'.
-% \item the \kl{instance} name (defining the scope, i.e. the region in which it is defined; no arobas in it), it is generated and dealt with by the \texttt{scope} package,
-% \item the \kl{knowledge} text itself.
+% \itemAP the namespace name (no arobas in it), each different use of the "knowledge@@package" package can use a different namespace. For the moment, this is always `default'.
+% \itemAP the \kl{instance} name (defining the scope, i.e. the region in which it is defined; no arobas in it). "Instances" are automatically generated, and the used should never has access to it.
+% \itemAP the \kl{knowledge} text itself.
% \end{itemize}
%
% The variable \cs{\knowledge_namespace_tl}
@@ -1568,7 +1684,7 @@ Content of the file knowledge-sources.zip:
\exp_args:Nc\ktuple_if_exist:NTF{\knowledge_id:nnn{#1}{#2}{#3}}
}
\cs_generate_variant:Nn
- \knowledge_knowledge_if_exist:nnnTF{VVVTF}
+ \knowledge_knowledge_if_exist:nnnTF{VVVTF,VnVTF}
% \end{macrocode}
%
%
@@ -1642,7 +1758,6 @@ Content of the file knowledge-sources.zip:
% \iffalse
% \begin{macrocode}
\NewDocumentCommand\NewKnowledgeParamTl{som}{
- %\tl_show:n{#2}
\IfNoValueTF{#2}
{ \tl_set:Nn\l_tmpa_tl{#3}
\tl_remove_all:Nn\l_tmpa_tl{~}
@@ -1745,7 +1860,7 @@ Content of the file knowledge-sources.zip:
% \item[\cs{\knowledge_visible_instances_seq}] contains the sequence
% of instances that are visible right now.
% \item[\csintro{\knowledge_scope_track_instance:Nn}\cs\tokenlist\{scope name\}]
-% sets \cs{\tokenlist} to the outermost instance of the scope name.
+% sets \cs{\tokenlist} to the innermost instance of the scope name.
% Typically, if the request is `\texttt{subsection}', the answer will be `\texttt{subsection-3.1}',
% identifying the subsection currently in scope.
% \end{compactdesc}
@@ -1760,45 +1875,59 @@ Content of the file knowledge-sources.zip:
% Note that \cs{\knowledge_visible_instances_seq} may only be correct after one compilation.
% \begin{compactdesc}
% \item[\csintro{\knowledge_push_visible_instance:n}]
-% \item[\csintro{\knowledge_pop_visible_instance:}]
+% \item[\csintro{\knowledge_push_visible_instance_mark:}] Inserts in \cs{\knowledge_visible_instances_seq} a special marker,
+% which is used when pushing a scope.
+% \item[\csintro{\knowledge_pop_visible_instances_to_mark:}] Pops everything till the special mark.
% \item[\csintro{\knowledge_pop_visible_instances_to:n}]
% \item[\csintro{\knowledge_show_visible_instances:}]
% \end{compactdesc}
%
% \begin{macrocode}
\seq_new:N\knowledge_visible_instances_seq
+% \end{macrocode}
+% Special marks are introduced for remembering till where to pop when a "scope" ends.
+% \begin{macrocode}
\cs_new:Nn\knowledge_push_visible_instance:n
{\seq_gpush:Nn\knowledge_visible_instances_seq{#1}}
-\cs_new:Npn\knowledge_pop_visible_instance:
- {\seq_gpop:NN\knowledge_visible_instances_seq\l_tmpa_tl}
-\cs_new:Nn\knowledge_pop_visible_instances_to:n
+\cs_new:Nn\knowledge_push_visible_instance_mark:
+ {\seq_gpush:Nn\knowledge_visible_instances_seq{|}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn\knowledge_pop_visible_instances_to_mark:
{\seq_gpop:NNTF\knowledge_visible_instances_seq\l_tmpa_tl
- {\exp_args:NV\tl_if_eq:nnTF\l_tmpa_tl{#1}
+ {\exp_args:NV\tl_if_eq:nnTF\l_tmpa_tl{|}
{}
- {\knowledge_pop_visible_instances_to:n{#1}}}
- {\INTERNAL_ERROR_EMPTY_POP_VISIBLE}}
+ {\knowledge_pop_visible_instances_to_mark:}}
+ {\KNOWLEDGE_INTERNAL_ERROR:_stack_of_visible_instances_is_empty_while_popping}}
+% \end{macrocode}
+% \begin{macrocode}
\cs_new:Nn\knowledge_show_visible_instances:
{\tl_show:x
{Visible~instances~<\seq_use:Nn\knowledge_visible_instances_seq{,}>}}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Nn\knowledge_import_instance:n
- {\seq_if_in:NnTF\knowledge_visible_instances_seq{#1}
- {}{\knowledge_push_visible_instance:n{#1}}}
+\NewDocumentCommand\knowledgeimport{ >{\SplitList{,}}m }{
+ \kl_hide_begin:
+ \ProcessList{#1}\knowledge_knowledgeimport:n
+ \kl_hide_end:
+}
% \end{macrocode}
% \begin{macrocode}
-\NewDocumentCommand\knowledgeimport{m}
- {\kl_hide_begin:
- \scopept_label_instance_if_exist:nTF{#1}
- {\exp_args:Nx\knowledge_import_instance:n{\scopept_label_instance_use:n{#1}}}
- {\msg_warning:nnnn{scope}{unknown~label}{#1}{\knowledgeimport}}
- \kl_hide_end:
-}
+\cs_set:Nn\knowledge_knowledgeimport:n{
+ \knowledge_scopetag_warn_if_unknown:n{#1}
+ \knowledge_scopetag_ensure:n{#1}
+ \exp_args:Nc\seq_map_function:NN
+ {\knowledge_scopetag_tl[#1]_seq}
+ \knowledge_push_visible_instance:n
+ }
% \end{macrocode}
%
%
% \subsubsection{The knowledge targeting}
-%%
+%
+% We define now the "directives" that are used for choosing how the "knowledge" should be defined.
+%
% \begin{macrocode}
\keys_define:nn { knowledge~directives } {
namespace .code:n = { \tl_set:Nn\knowledge_knowledge_namespace_tl{#1} },
@@ -1814,16 +1943,18 @@ Content of the file knowledge-sources.zip:
export / false .code:n = {\bool_set_false:N\knowledge_knowledge_export_bool},
export / true .code:n = {\bool_set_true:N\knowledge_knowledge_export_bool},
export .default:n = false,
- instance .code:n =
- { \tl_set:Nn\knowledge_knowledge_instance_tl{#1} },
+% instance .code:n =
+% { \tl_set:Nn\knowledge_knowledge_instance_tl{#1} },
+ link~instance .code:n =
+ { \tl_set:Nn\knowledge_knowledge_instance_tl{#1} },
scope .code:n =
- { \knowledge_scope_track_instance:Nn\knowledge_knowledge_instance_tl{#1} },
+ { \knowledge_scope_track_scope:n{#1}
+ \tl_gput_right:Nn\knowledge_knowledge_immediate_synonym_directives_tl{,scope = {#1}}},
synonym .code:n =
{ \bool_set_true:N\knowledge_knowledge_is_synonym_bool
\exp_args:Nnx\keys_set:nn { knowledge~directives }
- {link={\exp_not:o\knowledge_knowledge_synonym_tl},
- link~instance={\exp_not:o\knowledge_knowledge_synonyminstance_tl},
- instance={\exp_not:o\knowledge_knowledge_synonyminstance_tl}}}
+ {link={\exp_not:o\knowledge_knowledge_synonymlink_tl},
+ link~instance={\exp_not:V\knowledge_knowledge_synonyminstance_tl}}},
}
% \end{macrocode}
%
@@ -1860,6 +1991,8 @@ Content of the file knowledge-sources.zip:
{\knowledge_at:N\ktuple_new:N}
\keys_set:nn { knowledgenow~directives } { #4 }
}
+% \end{macrocode}
+% \begin{macrocode}
\cs_new:Nn\knowledge_set_now:nnnn
{\knowledge_sets_to:nnn{#1}{#2}{#3}
\knowledge_at:N\ktuple_if_exist:NTF
@@ -1869,6 +2002,8 @@ Content of the file knowledge-sources.zip:
{\knowledge_at:N\ktuple_new:N}
\keys_set:nn { knowledgenow~directives } { #4 }
}
+% \end{macrocode}
+% \begin{macrocode}
\cs_generate_variant:Nn\knowledge_new_now:nnnn{nnVn}
\cs_generate_variant:Nn\knowledge_set_now:nnnn{nnVn}
% \end{macrocode}
@@ -1879,13 +2014,13 @@ Content of the file knowledge-sources.zip:
% using \cs{\KAuxWriteLocation}, and then proceeds with \cs{\__knowledge_knowledge}.
% \begin{macrocode}
\NewDocumentCommand\knowledge{}
- {\KAuxWriteLocation\__knowledge_knowledge}
+ {\KAuxWriteLocation\__knowledge_knowledge_init:w}
% \end{macrocode}
% The command \csintro{\__knowledge_knowledge} is the center of the \cs{\knowledge}
% command. It parses its arguments (in particular separating the synonyms using the "xparse@@package"), and executes \cs{\knowledge_knowledge_process:nn}
% \begin{macrocode}
-\NewDocumentCommand\__knowledge_knowledge{t! t+ m >{\SplitList{|}}o m }
-{ \kl_hide_begin:
+\NewDocumentCommand\__knowledge_knowledge_init:w{t! t+ m m}{
+ \kl_hide_begin:
\group_begin:
%
\IfBooleanTF{#1}{%
@@ -1900,27 +2035,102 @@ Content of the file knowledge-sources.zip:
\tl_set_eq:NN\knowledge_namespace_tl
\knowledge_default_namespace_tl
%
+ \tl_gset:Nn\knowledge_knowledge_immediate_synonym_directives_tl{synonym}
+ %
\bool_gset_false:N\knowledge_knowledge_is_synonym_bool
%
+ \tl_if_eq:nnTF{#4}{|}
+ {\__knowledge_knowledge_cont_newsyntax:nw{#3}|}
+ {\tl_if_eq:nnTF{#4}{[}
+ {\__knowledge_knowledge_cont_classical:nw{#3}[}
+ {\__knowledge_knowledge_cont_classical:nw{#3}{#4}}}
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn\__knowledge_knowledge_recallsynonym:n{
+ \bool_if:NF\knowledge_knowledge_is_synonym_bool
+ {\tl_gset:Nn\knowledge_knowledge_synonymlink_tl{#1}
+ \tl_gset_eq:NN\knowledge_knowledge_synonyminstance_tl
+ \knowledge_knowledge_instance_tl}
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn\__knowledge_knowledge_end:{
+ \group_end:
+ \kl_hide_end:
+}
+% \end{macrocode}
+% \begin{macrocode}
+\NewDocumentCommand\__knowledge_knowledge_cont_classical:nw{m >{\SplitList{|}}o m }{
+ \knowledge_knowledge_setparseat:NNn\l_tmpa_tl\l_tmpb_tl{#1}
+ %
\use:x{
- \exp_not:n{\knowledge_knowledge_process:nn{#3}}
- {\exp_not:V\knowledge_knowledgedefault_tl,\exp_not:n{#5}}}
+ \exp_not:N\knowledge_knowledge_process:nn
+ {\exp_not:V\l_tmpa_tl}
+ {\exp_not:V\knowledge_knowledgedefault_tl,
+ \exp_not:n{#3},
+ \tl_if_empty:NTF\l_tmpb_tl{}{,scope={\exp_not:V\l_tmpb_tl}}}}
%
- \bool_if:NF\knowledge_knowledge_is_synonym_bool
- {\tl_gset:Nn\knowledge_knowledge_synonym_tl{#3}
- \tl_gset_eq:NN\knowledge_knowledge_synonyminstance_tl
- \knowledge_knowledge_instance_tl}
+ \exp_args:NV\__knowledge_knowledge_recallsynonym:n\l_tmpa_tl
%
- \IfNoValueTF{#4}{}{
+ \IfNoValueTF{#2}{}{
\cs_set:Nn\l_tmpa_cs:n
- {\exp_args:Nnx\knowledge_knowledge_process:nn{##1}{synonym}}
- \ProcessList{#4}\l_tmpa_cs:n
+ {\exp_args:Nnx\knowledge_knowledge_process:nn{##1}
+ {\exp_not:V\knowledge_knowledge_immediate_synonym_directives_tl}}
+ \ProcessList{#2}\l_tmpa_cs:n
}
%
- \group_end:
- \kl_hide_end:
+ \__knowledge_knowledge_end:
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn\knowledge_knowledge_newsyntax_firstline:n{}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn\knowledge_knowledge_newsyntax_nextlines:n{}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn\__knowledge_knowledge_cont_newsyntax:nw#1{
+ \cs_set:Nn\knowledge_knowledge_newsyntax_firstline:n
+ {\knowledge{##1}{#1}
+ \cs_set_eq:NN
+ \knowledge_knowledge_newsyntax_exec_line:n
+ \knowledge_knowledge_newsyntax_nextlines:n}
+ \cs_set:Nn\knowledge_knowledge_newsyntax_nextlines:n
+ {\exp_args:Nnx\knowledge{##1}
+ {\exp_not:V\knowledge_knowledge_immediate_synonym_directives_tl}}
+ \cs_set_eq:NN
+ \knowledge_knowledge_newsyntax_exec_line:n
+ \knowledge_knowledge_newsyntax_firstline:n
+ \kl_newknowledge_parse:w
}
% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn\kl_newknowledge_parse:w{
+ \peek_charcode_remove_ignore_spaces:NTF|
+ {\kl_insert_klendline:w\knowledge_knowledge_newsyntax_exec_line:w}
+ {\__knowledge_knowledge_end:}
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn\knowledge_knowledge_newsyntax_exec_line:w#1\kl_end_line:{
+ \knowledge_knowledge_newsyntax_exec_line:n{#1}
+ \kl_newknowledge_parse:w
+}
+% \end{macrocode}
+% \begin{macrocode}
+\char_set_catcode_active:N\^^M
+\cs_gset:Npn\kl_insert_klendline:w{\group_begin:\catcode`\^^M=\active\kl_insert_klendline_:w}
+\cs_gset:Npn\kl_insert_klendline_:w#1^^M{\group_end:#1\kl_end_line:}
+\char_set_catcode_end_line:N\^^M
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn\knowledge_knowledge_setparseat:NNn
+ {\knowledge_knowledge_setparseat_:NNw#1#2#3@@\kl_end:}
+\cs_new:Npn\knowledge_knowledge_setparseat_:NNw#1#2#3@#4@#5\kl_end:
+ {\tl_set:Nx#1{\tl_trim_spaces:n{#3}}
+ \tl_set:Nx#2{\tl_trim_spaces:n{#4}}}
+% \end{macrocode}
%
%\AP The boolean \cs{\knowledge_knowledgestyle_bool}
% is set to true in order \cs{\knowledge_knowledge_process:nn}
@@ -1950,6 +2160,25 @@ Content of the file knowledge-sources.zip:
%\AP The \cs{\knowledge_knowledge_process:nn} command is the internal
% version of \cs{\knowledge}. It takes two parameters:
% the key, and the comma separated list of directives.
+% It uses internally the following `variables':
+% \begin{asparadesc}
+% \itemAP[\csintro{\knowledge_knowledgestyle_bool}] is it a \cs{\knowledgestyle} macro?
+% \itemAP[\csintro{\knowledge_knowledgestyle_override_bool}] has it been required to override a previous "knowledge"?
+% \itemAP[\csintro{\knowledge_knowledge_now_bool}] set if in the preamble or by the directive "now".
+% \itemAP[\csintro{\knowledge_knowledge_alsonow_bool}] set by directive "also now".
+% \itemAP[\csintro{\knowledge_knowledge_is_synonym_bool}] set by the "synonym" directive.
+% \itemAP[\csintro{\knowledge_knowledge_autoref_bool}] set by the "autoref" directive
+% \itemAP[\csintro{\knowledge_knowledge_clear_bool}]
+% \itemAP[\csintro{\knowledge_knowledge_append_bool}]
+% \itemAP[\csintro{\knowledge_knowledge_export_bool}]
+% \itemAP[\csintro{\knowledge_knowledge_synonymlink_tl}] name of the "knowledge" to link to if a "synonym" directive is used.
+% \itemAP[\csintro{\knowledge_knowledge_synonyminstance_tl}] "instance" of the "knowledge" to link if a "synonym" directive is used.
+% \itemAP[\csintro{\knowledge_knowledge_immediate_synonym_directives_tl}] gathers the "directives" that have to be propagated to implicit synonyms.
+% \itemAP[\csintro{\knowledge_knowledge_key_tl}] the text for which the "knowledge" has to be defined.
+% \itemAP[\csintro{\knowledge_knowledge_namespace_tl}] the "namespace".
+% \itemAP[\csintro{\knowledge_knowledge_instance_tl}]
+% \itemAP[\csintro{\knowledge_knowledge_directives_tl}] gathers the "directives" that have to be executed for defining the "knowledge" (either to be executed now if \cs{\knowledge_knowledge_now_bool} is set, or to be propagated to the "kaux file" for execution during the next compilation phase)
+% \end{asparadesc}
% \begin{macrocode}
\bool_new:N\knowledge_knowledgestyle_bool
\bool_new:N\knowledge_knowledgestyle_override_bool
@@ -1959,8 +2188,9 @@ Content of the file knowledge-sources.zip:
\bool_new:N\knowledge_knowledge_autoref_bool
\bool_new:N\knowledge_knowledge_clear_bool
\bool_new:N\knowledge_knowledge_append_bool
-\tl_clear_new:N\knowledge_knowledge_synonym_tl
+\tl_clear_new:N\knowledge_knowledge_synonymlink_tl
\tl_clear_new:N\knowledge_knowledge_synonyminstance_tl
+\tl_clear_new:N\knowledge_knowledge_immediate_synonym_directives_tl
\tl_clear_new:N\knowledge_knowledge_export_bool
\tl_clear_new:N\knowledge_knowledge_key_tl
\tl_clear_new:N\knowledge_knowledge_namespace_tl
@@ -2050,17 +2280,24 @@ Content of the file knowledge-sources.zip:
% \subsubsection{The \cs{\knowledgedirective} command}
%
% \begin{macrocode}
-\NewDocumentCommand\knowledgedirective{mom}{
+\NewDocumentCommand\knowledgedirective{smom}{
\kl_hide_begin:
- \cs_new:cn
- {knowledgedirective_#1:n}
- {\keys_set:nn{ knowledge~directives }{#3}}
- \keys_define:nn{ knowledge~directives }
- {#1 .code:n = {\use:c{knowledgedirective_#1:n}{##1}}}
- \IfNoValueF{#2}
- {\keys_define:nn{ knowledge~directives }{#1 .default:n = {#2}}}
+ \keys_if_exist:nnTF{ knowledge~directives }{ #2 }
+ {\IfBooleanTF{#1}
+ {\knowledgedirective:nnn{#2}{#3}{#4}}
+ {\msg_error:nnn{ knowledge }{ knowledgedirective~redifinition }{#2}}}
+ {\knowledgedirective:nnn{#2}{#3}{#4}}
\kl_hide_end:
}
+\cs_new:Nn\knowledgedirective:nnn{
+ \cs_set:cn
+ {knowledgedirective_#1:n}
+ {\keys_set:nn{ knowledge~directives }{#3}}
+ \keys_define:nn{ knowledge~directives }
+ {#1 .code:n = {\use:c{knowledgedirective_#1:n}{##1}}}
+ \IfNoValueF{#2}
+ {\keys_define:nn{ knowledge~directives }{#2 .default:n = {#2}}}
+}
% \end{macrocode}
%
% \subsubsection{The \cs{\knowledgedefault} command}
@@ -2170,14 +2407,12 @@ Content of the file knowledge-sources.zip:
% 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:{
+\cs_new:Nn\knowledge_kl_find:{
\knowledge_kl_find_recursion_exceeded:TF
- {\knowledge_kl_error_recursion:}
- {\tl_if_empty:NTF\knowledge_kl_instance_tl
- {\tl_if_empty:NTF\knowledge_kl_linkscope_tl
+ \knowledge_kl_error_recursion:
+ {\tl_if_empty:NTF\knowledge_kl_linkscope_tl
\knowledge_kl_find_withoutscope:
- \knowledge_kl_find_withscope:}
- \knowledge_kl_find_withinstance:}
+ \knowledge_kl_find_withscopetag:}
}
% \end{macrocode}
% \begin{macrocode}
@@ -2199,13 +2434,39 @@ Content of the file knowledge-sources.zip:
\knowledge_kl_key_tl}
{ \knowledge_kl_error_unknown_in_scope_firsttime: }
}
-\cs_new:Nn\knowledge_kl_find_withscope:{
- \exp_args:NV
- \scopept_label_instance_if_exist:nTF\knowledge_kl_linkscope_tl
- { \tl_set:Nx\knowledge_kl_instance_tl
- {\scopept_label_instance_use:n{\knowledge_kl_linkscope_tl}}
- \knowledge_kl_find_withinstance: }
- { \knowledge_kl_error_label_unknown: }
+% \end{macrocode}
+% \csintro{\knowledge_kl_find_withscopetag:} searches for the knowledge, with a given scopetag
+% \begin{macrocode}
+\cs_new:Nn\knowledge_kl_find_withscopetag:{
+ \exp_args:NV\knowledge_scopetag_warn_if_unknown:n\knowledge_kl_linkscope_tl
+ \tl_clear:N\l_tmpa_tl
+ \exp_args:Nc\seq_map_function:NN
+ {\knowledge_scopetag_tl[\knowledge_kl_linkscope_tl]_seq}
+ \knowledge_kl_find_scopetag_tmpa:n
+ \tl_if_empty:NTF\l_tmpa_tl
+ {\knowledge_kl_error_unknown_in_scope_firsttime:}
+ {\knowledge_kl_exec:VVV
+ \knowledge_kl_namespace_tl
+ \l_tmpa_tl
+ \knowledge_kl_key_tl}
+}
+% \end{macrocode}
+% \csintro{\knowledge_kl_find_scopetag:Nn} takes a token list for the result, and
+% a scopetag as argument. If the tl is empty, and a knowledge using scopetag as instance is found,
+% then the scopetag is transfered to the token list.
+% \begin{macrocode}
+\cs_new:Nn\knowledge_kl_find_scopetag:Nn{
+ \tl_if_empty:NTF#1
+ {\knowledge_knowledge_if_exist:VnVTF
+ \knowledge_kl_namespace_tl
+ {#2}%instance
+ \knowledge_kl_key_tl
+ {\tl_set:Nn#1{#2}}
+ {}}
+ {}
+}
+\cs_new:Npn\knowledge_kl_find_scopetag_tmpa:n{
+ \knowledge_kl_find_scopetag:Nn\l_tmpa_tl
}
% \end{macrocode}
% \begin{macrocode}
@@ -2220,16 +2481,17 @@ Content of the file knowledge-sources.zip:
{\knowledge_kl_error_unknown_firsttime:}
}
% \end{macrocode}
-% We now code the macro \cs{\knowledge_kl_find_in_scope:nnNTF}, that
-% takes the \kl{namespace}, and the \kl{knowledge}, and answers the \kl{instance} (if it exists),
-% and sets the tl-token (third argument) to contain the scope in which it has been found.
+% \cs{\knowledge_kl_find_in_scope:nNTF} introduces the namespace as
+% first argument in a call to \cs{\knowledge_kl_find_in_scope:nnNTF}
% \begin{macrocode}
\cs_new:Npn\knowledge_kl_find_in_scope:nNTF{
\exp_args:NV\knowledge_kl_find_in_scope:nnNTF
\knowledge_kl_namespace_tl
}
% \end{macrocode}
-%
+% We now code the macro \cs{\knowledge_kl_find_in_scope:nnNTF}, that
+% takes the \kl{namespace}, and the \kl{knowledge}, and answers the \kl{instance} (if it exists),
+% and sets the tl-token (third argument) to contain the scope in which it has been found.
% \begin{macrocode}
\cs_new:Nn\knowledge_kl_find_in_scope:nnNTF{
\group_begin:
@@ -2245,13 +2507,29 @@ Content of the file knowledge-sources.zip:
{#5}
}
% \end{macrocode}
+% \cs{\knowledge_kl_find_in_scope_test:n} tests the existence of a "knowledge"
+% in the "scopetag" given as argument. For this it searches through all the instances associated to the
+% scopetag, and sets \cs{\g_tmpa_bool} when found.
+% One has to check that the visible instance is not the mark.
% \begin{macrocode}
\cs_new:Nn\knowledge_kl_find_in_scope_test:n{
+ \tl_if_eq:nnTF{#1}{|}{}{
+ \knowledge_kl_find_in_scope_test_:n{#1}
+ \seq_if_exist:cTF{\knowledge_scopetag_tl[#1]_seq}
+ {\exp_args:Nc\seq_map_function:NN
+ {\knowledge_scopetag_tl[#1]_seq}
+ \knowledge_kl_find_in_scope_test_:n
+ }{}}
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn\knowledge_kl_find_in_scope_test_:n{
\exp_args:Nc\ktuple_if_exist:NTF
{\knowledge_id:nnV{\l_tmpa_tl}{#1}\l_tmpb_tl}
{\bool_gset_true:N\g_tmpa_bool
\tl_gset:Nn\g_tmpa_tl{#1}
- \seq_map_break:}{}}
+ \seq_map_break:}{}
+}
% \end{macrocode}
% \begin{macrocode}
\cs_generate_variant:Nn\knowledge_kl_find_in_scope:nnNTF{nVNTF}
@@ -2303,7 +2581,7 @@ Content of the file knowledge-sources.zip:
\knowledge_kl_compute_code:
}
}
-\cs_generate_variant:Nn\knowledge_kl_exec:nnn{nnV}
+\cs_generate_variant:Nn\knowledge_kl_exec:nnn{nnV,VVV}
% \end{macrocode}
% \begin{macrocode}
\cs_new:Nn\knowledge_kl_use_styles:n
@@ -2369,13 +2647,25 @@ Content of the file knowledge-sources.zip:
% \begin{macrocode}
\DeclareKAuxPhaseCommand\KAuxErrorKnowledgeUnknown{diagnose-unknown-suggest}
{ \knowledge_diagnose_line:
- \tl_set_eq:Nc\l_tmpa_tl{knowledge_kl_\cs_to_str:N#5_suggestion_tl}
- \tl_if_empty:nTF{#2}{}
- {\tl_if_empty:NTF\l_tmpa_tl{}
- {\tl_put_right:Nn\l_tmpa_tl{,}}
- \tl_put_right:Nn\l_tmpa_tl{scope={#2}}}
- \knowledge_diagnose:x
- {\exp_not:n{\knowledge{#3}}{\exp_not:V\l_tmpa_tl}}
+ \tl_set_eq:Nc\l_tmpa_tl{knowledge_kl_\cs_to_str:N#5_suggestion_tl}
+ \tl_if_eq:nnTF{#1}{default}
+ {}
+ {\tl_if_empty:NTF\l_tmpa_tl{}{\tl_put_right:Nn\l_tmpa_tl{,}
+ \tl_put_right:Nn\l_tmpa_tl{namespace={#1}}}}
+
+ \bool_if:NTF\knowledge_configuration_barsuggestion_bool{
+ %\knowledge_diagnose:x{\char_escape_tl knowledge{\exp_not:V\l_tmpa_tl}}
+ \tl_set:Nn\l_tmpa_tl{~~~|~~#3}
+ \tl_if_empty:nTF{#2}{}
+ {\tl_put_right:Nn\l_tmpa_tl{@#2}}
+ \knowledge_diagnose:x{\exp_not:V\l_tmpa_tl}
+ }{
+ \tl_if_empty:nTF{#2}{}
+ {\tl_if_empty:NTF\l_tmpa_tl{}{\tl_put_right:Nn\l_tmpa_tl{,}}
+ \tl_put_right:Nn\l_tmpa_tl{scope={#2}}}
+ \knowledge_diagnose:x
+ {\char_escape_tl knowledge\exp_not:n{{#3}}{\exp_not:V\l_tmpa_tl}}
+ }
}
% \end{macrocode}
% The code executed when an undefined knowledge is met. It
@@ -2386,7 +2676,7 @@ Content of the file knowledge-sources.zip:
\msg_warning:nnxxx{ knowledge }{ knowledge~unknown }
{\exp_not:V\knowledge_kl_key_tl}
{\exp_not:V\knowledge_kl_namespace_tl}
- {\seq_use:Nn\knowledge_visible_instances_seq{~|~}}}
+ {\seq_use:Nn\knowledge_visible_instances_seq{|}}}
}{}
\bool_if:cTF{\knowledge_variant_var:n{unknowndiagnose_bool}}
{\KAuxWriteX{
@@ -2514,36 +2804,38 @@ Content of the file knowledge-sources.zip:
% \end{macrocode}
% \begin{macrocode}
\NewDocumentCommand\knowledgenewvariant{mm}{
- \exp_args:Nc\tl_new:Nn
+ \tl_if_exist:cTF{knowledge_kl_\cs_to_str:N#1_command_tl}
+ {\knowledge_error:n{Variant~#1~already~exists~(in~\knowledgenewvariant).}}
+ {\exp_args:Nc\tl_new:Nn
{knowledge_kl_\cs_to_str:N#1_command_tl}
{#1}
- %
- %
- \NewDocumentCommand#1{s}
- {\knowledge_kl_modifiers_add:N#1
- \IfBooleanF{##1}{\knowledge_kl:w}}
- %
- \tl_new_eq:cN
- {knowledge_kl_\cs_to_str:N#1_namespace_tl}
- \knowledge_default_namespace_tl
- \tl_new:cx{knowledge_kl_\cs_to_str:N#1_suggestion_tl}{}
- \bool_new_true:c{knowledge_kl_\cs_to_str:N#1_unknownwarning_bool}
- \bool_new_true:c{knowledge_kl_\cs_to_str:N#1_unknowndiagnose_bool}
- \tl_new:cn{knowledge_kl_\cs_to_str:N#1_default_style_tl}{}
- \tl_new:cn{knowledge_kl_\cs_to_str:N#1_unknown_style_tl}{}
- \tl_new:cn{knowledge_kl_\cs_to_str:N#1_unknown_style_cont_tl}{}
- \tl_new:cx{knowledge_kl_\cs_to_str:N#1_autoknowledge_tl}{}
- \tl_new:cx{knowledge_kl_\cs_to_str:N#1_styledirectives_tl}{}
- %
- \bool_if:NT\knowledge_hyperref_active_bool
- {\exp_args:Nx\pdfstringdefDisableCommands
- {\exp_not:N\def\exp_not:N#1
- {\exp_not:N\knowledge_variant_arg_absorber:Nw
- \exp_not:c{\cs_to_str:N#1_PDFstring}}}}
- \exp_args:Nc\newcommand{\cs_to_str:N#1_PDFstring}[3]{##1}
- %
- \tl_new:cx{knowledge_kl_\tl_to_str:n{#1*} _init_tl}
- {
+ %
+ %
+ \NewDocumentCommand#1{s}
+ {\knowledge_kl_modifiers_add:N#1
+ \IfBooleanF{##1}{\knowledge_kl:w}}
+ %
+ \tl_new_eq:cN
+ {knowledge_kl_\cs_to_str:N#1_namespace_tl}
+ \knowledge_default_namespace_tl
+ \tl_new:cx{knowledge_kl_\cs_to_str:N#1_suggestion_tl}{}
+ \bool_new_true:c{knowledge_kl_\cs_to_str:N#1_unknownwarning_bool}
+ \bool_new_true:c{knowledge_kl_\cs_to_str:N#1_unknowndiagnose_bool}
+ \tl_new:cn{knowledge_kl_\cs_to_str:N#1_default_style_tl}{}
+ \tl_new:cn{knowledge_kl_\cs_to_str:N#1_unknown_style_tl}{}
+ \tl_new:cn{knowledge_kl_\cs_to_str:N#1_unknown_style_cont_tl}{}
+ \tl_new:cx{knowledge_kl_\cs_to_str:N#1_autoknowledge_tl}{}
+ \tl_new:cx{knowledge_kl_\cs_to_str:N#1_styledirectives_tl}{}
+ %
+ \bool_if:NT\knowledge_hyperref_active_bool
+ {\exp_args:Nx\pdfstringdefDisableCommands
+ {\exp_not:N\def\exp_not:N#1
+ {\exp_not:N\knowledge_variant_arg_absorber:Nw
+ \exp_not:c{\cs_to_str:N#1_PDFstring}}}}
+ \exp_args:Nc\newcommand{\cs_to_str:N#1_PDFstring}[3]{##1}
+ %
+ \tl_new:cx{knowledge_kl_\tl_to_str:n{#1*} _init_tl}
+ {
\exp_not:n{\tl_set_eq:NN\knowledge_kl_command_tl}
\exp_not:c{knowledge_kl_\cs_to_str:N#1_command_tl}
\exp_not:n{\tl_set_eq:NN\knowledge_kl_namespace_tl}
@@ -2558,10 +2850,11 @@ Content of the file knowledge-sources.zip:
\exp_not:c{knowledge_kl_\cs_to_str:N#1 _styledirectives_tl}
\exp_not:c{knowledge_kl_\cs_to_str:N#1 _autoknowledge_tl}
}
- %
- %\bool_if:NT\knowledge_hyperref_active_bool
- % {\pdfstringdefDisableCommands{\let#1\knowledge_fake_kl:n}}
- %
+ %
+ %\bool_if:NT\knowledge_hyperref_active_bool
+ % {\pdfstringdefDisableCommands{\let#1\knowledge_fake_kl:n}}
+ %
+ }
\knowledgesetvariant#1{#2}
}
\DeclareExpandableDocumentCommand\knowledge_variant_arg_absorber:Nw
@@ -2573,10 +2866,14 @@ Content of the file knowledge-sources.zip:
\tl_new:N\knowledge_variant_command_tl
\tl_new:N\knowledge_variant_key_tl
\NewDocumentCommand\knowledgesetvariant{mm}{
- \tl_set:Nn\knowledge_variant_command_tl{#1}
- \tl_set:Nx\knowledge_variant_key_tl{\cs_to_str:N#1}
- %
- \keys_set:nn{ knowledge~configure~variant }{#2}
+ \tl_if_exist:cTF{knowledge_kl_\cs_to_str:N#1_command_tl}
+ {
+ \tl_set:Nn\knowledge_variant_command_tl{#1}
+ \tl_set:Nx\knowledge_variant_key_tl{\cs_to_str:N#1}
+ %
+ \keys_set:nn{ knowledge~configure~variant }{#2}
+ }
+ {\knowledge_error:n{Variant~#1~does~not~exist~(in~\knowledgesetvariant).}}
}
% \end{macrocode}
% \begin{macrocode}
@@ -2738,7 +3035,7 @@ Content of the file knowledge-sources.zip:
%
% \begin{macrocode}
\NewKnowledgeParamTl*{link}
-\NewKnowledgeParamTl*{link~scope}
+\NewKnowledgeParamTl*[\knowledge_kl_linkscope_tl]{link~scope}
\NewKnowledgeParamTl*[\knowledge_kl_instance_tl]{link~instance}
\NewKnowledgeParamTl*[\knowledge_kl_forcedtext_tl]{text}
\NewKnowledgeParamTl*{wrap}
@@ -2748,7 +3045,7 @@ Content of the file knowledge-sources.zip:
% \begin{macrocode}
\NewKnowledgeParamBool*{UnKnoWn~KNowLedGE}\kl_unknown_knowledge_bool
-\bool_gset_false:N\kl_unknown_knowledge_bool
+\bool_set_false:N\kl_unknown_knowledge_bool
\ktuple_new_int_index:n{countuse}
\ktuple_countuse_expands_to:n{}
\ktuple_new_int_index:n{countintro}
@@ -2839,7 +3136,7 @@ Content of the file knowledge-sources.zip:
\int_compare:nNnT\kl_countuse_int>0
{\int_compare:nNnT\kl_countintro_int=0
{\knowledge_diagnose_line:
- \knowledge_diagnose:n{\nointro{#1}{#2}{#3}}}}
+ \knowledge_diagnose:x{\char_escape_tl nointro{\exp_not:n{#1}}{\exp_not:n{#2}}{\exp_not:n{#3}}}}}
\group_end:}
\DeclareKAuxPhaseCommand\KAuxAutoref{autoref-introduced-not-used}
{\group_begin:
@@ -2975,7 +3272,7 @@ Content of the file knowledge-sources.zip:
\tl_set:Nx\l_tmpa_tl
{\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}}
+ \exp_args:Nx\LaTeXlabel{\exp_not:V\knowledge_kl_autoref_tl\l_tmpa_tl}}
\expandafter\ktuple_countintro_gincr:N
\knowledge_kl_resourcetoken_tl
\KAuxWriteX
@@ -2999,7 +3296,7 @@ Content of the file knowledge-sources.zip:
% {\bool_if:NTF\kl_fbox_bool{\exp_not:N\fbox{#1}}{#1}}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Npn\kl_up:n{\mode_if_math:TF\mathup\textup}
+\cs_new:Npn\kl_up:n{\mode_if_math:TF\use:n\textup}
\cs_new:Npn\kl_md:n{\mode_if_math:TF\mathmd\textmd}
\cs_new:Npn\kl_sc:n{\mode_if_math:TF\mathsc\textsc}
\cs_new:Npn\kl_it:n{\mode_if_math:TF\mathit\textit}
@@ -3497,14 +3794,14 @@ Content of the file knowledge-sources.zip:
\knowledgenewvariant\kl{
namespace= default,
- default style= {kl,autoref link},
+ default style= {autoref link},
unknown style= kl unknown,
unknown style cont= kl unknown cont,
- style directive={style}
+ style directive= style
}
\knowledgenewvariant\intro{
namespace= default,
- default style= {intro,autoref target},
+ default style= {autoref target},
unknown style= intro unknown,
unknown style cont= intro unknown cont,
style directive= intro style
@@ -3517,11 +3814,13 @@ Content of the file knowledge-sources.zip:
}
\knowledgenewvariant\reintro{
namespace=default,
- default style=intro,
+% default style=intro,
unknown style=intro unknown,
unknown style cont=intro unknown cont,
style directive=intro style
}
+
+
\knowledgevariantmodifier{\intro*\kl}{\intro}
\knowledgevariantmodifier{\reintro*\kl}{\reintro}
@@ -3544,27 +3843,27 @@ Content of the file knowledge-sources.zip:
\ExplSyntaxOff
% in paper mode, nothing is displayed
\IfKnowledgePaperModeTF{
- \knowledgestyle{kl}{}
+% \knowledgestyle{kl}{}
\knowledgestyle{kl unknown}{}
\knowledgestyle{kl unknown cont}{}
- \knowledgestyle{intro}{emphasize,index style=knowledgeIntroIndexStyle}
+% \knowledgestyle{intro}{emphasize,index style=knowledgeIntroIndexStyle}
\knowledgestyle{intro unknown}{emphasize}
\knowledgestyle{intro unknown cont}{emphasize}
}{}
\IfKnowledgeCompositionModeTF{
\IfXcolorTF{
- \knowledgestyle{kl}{color={blue!70!black}}
+% \knowledgestyle{kl}{color={blue!70!black}}
\knowledgestyle{kl unknown}{color=orange}
\knowledgestyle{kl unknown cont}{color=brown}
- \knowledgestyle{intro}{emphasize,color=blue,index style=knowledgeIntroIndexStyle}
+% \knowledgestyle{intro}{emphasize,color=blue,index style=knowledgeIntroIndexStyle}
\knowledgestyle{intro unknown}{emphasize,color=orange}
\knowledgestyle{intro unknown cont}{emphasize,color=brown}
}{
- \knowledgestyle{kl}{}
+% \knowledgestyle{kl}{}
\knowledgestyle{kl unknown}{underline}
\knowledgestyle{kl unknown cont}{underline}
- \knowledgestyle{intro}{emphasize,index style=introindexstyle}
+% \knowledgestyle{intro}{emphasize,index style=introindexstyle}
\knowledgestyle{intro unknown}{emphasize,underline}
\knowledgestyle{intro unknown cont}{emphasize,underline}
}
@@ -3572,17 +3871,17 @@ Content of the file knowledge-sources.zip:
\IfKnowledgeElectronicModeTF{
\IfXcolorTF{
- \knowledgestyle{kl}{color={blue!70!black}}
+% \knowledgestyle{kl}{color={blue!70!black}}
\knowledgestyle{kl unknown}{}
\knowledgestyle{kl unknown cont}{}
- \knowledgestyle{intro}{emphasize,color=blue,index style=introindexstyle}
+% \knowledgestyle{intro}{emphasize,color=blue,index style=introindexstyle}
\knowledgestyle{intro unknown}{emphasize}
\knowledgestyle{intro unknown cont}{emphasize}
}{
- \knowledgestyle{kl}{}
+% \knowledgestyle{kl}{}
\knowledgestyle{kl unknown}{}
\knowledgestyle{kl unknown cont}{}
- \knowledgestyle{intro}{emphasize,index style=introindexstyle}
+% \knowledgestyle{intro}{emphasize,index style=introindexstyle}
\knowledgestyle{intro unknown}{emphasize}
\knowledgestyle{intro unknown cont}{emphasize}
}