summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/knowledge
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-07-28 21:42:49 +0000
committerKarl Berry <karl@freefriends.org>2017-07-28 21:42:49 +0000
commitbe3a88d7e7d41e6a88a01a9c320767140e93ecd0 (patch)
tree626c86772920ed08ab8023be97eba65b8244b0cc /Master/texmf-dist/tex/latex/knowledge
parent81092d86348e2ce483ff79f789764cad14eb2aa7 (diff)
knowledge (28jul17)
git-svn-id: svn://tug.org/texlive/trunk@44904 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/knowledge')
-rw-r--r--Master/texmf-dist/tex/latex/knowledge/knowledge.sty853
1 files changed, 562 insertions, 291 deletions
diff --git a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty
index b566866f7fa..eccc94e1443 100644
--- a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty
+++ b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty
@@ -5,11 +5,12 @@
%% The original source files were:
%%
%% knowledge.dtx (with options: `head')
-%% knowledgeutils.dtx (with options: `package')
+%% knowledge-utils.dtx (with options: `package')
%% knowledge.dtx (with options: `package')
-%% scopearticle.dtx (with options: `package')
+%% knowledge-configuration.dtx (with options: `package')
+%% knowledge.dtx (with options: `tail')
%%
-%% This is a generated file. Copyright (C) 2016 by Thomas Colcombet
+%% This is a generated file. Copyright (C) 2017 by Thomas Colcombet
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -21,23 +22,16 @@
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
%%
-%%%%%%%%%%
\usepackage{expl3}
-\ProvidesExplPackage{knowledge}{2017/06/11}{v1.01}{}
+\ProvidesExplPackage{knowledge}{2017/07/28}{v1.04}{}
+%%%%%%%%%%
\RequirePackage{l3keys2e}
\RequirePackage{etoolbox}
-\RequirePackage[log-declarations=false]{xparse}
+\RequirePackage{xparse}
\bool_if_exist:NTF\knowledge_package_loaded_bool
{\endinput}
{\bool_set_true:N\knowledge_package_loaded_bool}
-\cs_new:Npn\knowledge_skip_module:#1\knowledge_end_module:
- {}
-\cs_new:Nn\knowledge_begin_module_if:N
- {\bool_if:NF#1\knowledge_skip_module:}
-\cs_new:Nn\knowledge_end_module:
- {}
-
\usepackage{xparse}
\usepackage{currfile}
\tl_if_exist:NTF
@@ -251,7 +245,6 @@
\tl_new:N\kauxCurrentFile
\tl_new:N\kauxCurrentLine
-
\bool_new:N\kaux_can_be_used_bool
\bool_gset_false:N\kaux_can_be_used_bool
@@ -737,6 +730,12 @@
\cs_new:Nn\kutils_latex_to_obsolete:n
{\tl_map_function:nN{#1}\kutils_latex_to_obsolete:N}
%%%%%%%%%%
+\cs_new:Npn\knowledge_skip_module:#1\knowledge_end_module:
+ {}
+\cs_new:Nn\knowledge_begin_module_if:N
+ {\bool_if:NF#1\knowledge_skip_module:}
+\cs_new:Nn\knowledge_end_module:
+ {}
\cs_set_eq:Nc\klparse_ifnextchar:NTF{@ifnextchar}
\NewDocumentCommand\klparse_setnovalue{o}
@@ -747,12 +746,56 @@
{\tl_if_eq:NNTF\klparse_novalue_tl}
\cs_new:Nn\knowledge_info:n{\msg_info:nnn{knowledge}{knowledge~info}{#1}}
\cs_new:Nn\knowledge_warning:n{\msg_warning:nnn{knowledge}{knowledge~warning}{#1}}
+\cs_new:Nn\knowledge_error:n{\msg_error:nnn{knowledge}{knowledge~error}{#1}}
\msg_new:nnnn{knowledge}{knowledge~info}{#1}{#2}
\msg_new:nnnn{knowledge}{knowledge~warning}{#1}{#2}
+\msg_new:nnnn{knowledge}{knowledge~error}{#1}{#2}
\cs_generate_variant:Nn\knowledge_info:n{x}
\cs_generate_variant:Nn\knowledge_warning:n{x}
+\cs_generate_variant:Nn\knowledge_error:n{x}
+\msg_new:nnn{ knowledge }{ knowledge~recursion }
+ { The~knowledges~are~probably~cyclic,~starting~from~'#1'~(namespace~'#2'),~
+ currently~at~'#3'.}
+\msg_new:nnn{ knowledge }{ knowledge~unknown }
+ {The~knowledge~'#1'~could~not~be~found~in~scopes~<~#3~>~(namespace~'#2').}
+\msg_new:nnn{ knowledge }{ knowledge~unknown~in~scope }
+ {The~knowledge~'#1'~could~not~be~found~in~scope~'#3'~(namespace~'#2').}
+\msg_new:nnn{ knowledge }{ knowledge~unknown~label }
+ {The~label~'#2'~could~not~be~found~while~searching~for~'#1'.~Possibly~rerun~latex.}
+
+\msg_new:nnn{ knowledge }{ package~required }
+ {In~order~to~use~directive~'#1',~please~load~package~or~use~option~'#2'.}
+\msg_new:nnn{ knowledge }{ knowledge~exists }
+ { The~knowledge~'#1'~in~scope~'#2'~(namespace~'#3')~already~exists. }
+
+\msg_new:nnn{scope}{area~exists}{Area~'#1'~already~exists.}
+\msg_new:nnn{scope}{area~not~exist}{Area~'#1'~does~not~exist.}
+\msg_new:nnn{scope}{empty~pop}{Attempt~to~pop~an~empty~area~stack.}
+\msg_new:nnn{scope}{no~pushing~here}
+ {Not~allowed~to~open~'\scope_pushed_area_tl'~here.~
+ Current~stack~is~<\seq_use:Nn\scope_instances_stack_seq{::}>.}
+\msg_new:nnn{scope}{no~popping}{Not~allowed~to~close~'\scope_popped_area_tl'.}
+\msg_new:nnn{scope}{no~popping~here}
+ {Not~allowed~to~close~'\scope_popped_area_tl'~here~(at~'\scope_top_area_tl').}
+\msg_new:nnn{scope}{unknown~label}
+ {\tl_if_empty:nTF{#2}{}{\exp_not:n{#2}}:
+ ~Unknown~label~`#1'.~Possibly~rerun~latex.}
+\msg_new:nnn{scope}{area~not~in~context}
+ {\tl_if_empty:nTF{#2}{}{\exp_not:n{#2}}:
+ ~The~area~`#1'~can't~be~found~in~context.~Possibly~rerun~latex.}
+\NewKAuxCommand\KAuxErrorKnowledgeRecursive{mmmm}
+ {Package~'knowledge:~A~knowledge~has~recursive~definition.~
+ {namespace}{scope}{undefined~knowledge}{base~knowledge}}
+ {}
+\cs_new:Nn\knowledge_kl_error_recursion: {
+ \msg_error:nnxxx{ knowledge }{ knowledge~recursion }
+ {\exp_not:V\knowledge_kl_base_key_tl}
+ {\exp_not:V\knowledge_kl_namespace_tl}
+ {\exp_not:V\knowledge_kl_key_tl}
+ \knowledge_kl_error_display:n{recursive~knowledge}
+}
\tl_new:N\knowledge_configuration_pending_tl
\tl_set:Nn\knowledge_configuration_pending_tl{}
\NewDocumentCommand\KnowledgePackageTrigger{mm}
@@ -812,14 +855,13 @@
\keys_define:nn{ knowledge~configuration~options }{
#2 .code:n = {\OPTION_CANNOT_BE_USED_IN_knowledgeconfigure}
}}
-
\NewDocumentCommand\KnowledgeConfigureTrigger{omm}{
\IfNoValueTF{#1}
{\tl_set:Nn\l_tmpa_tl{#2}
\tl_remove_all:Nn\l_tmpa_tl{~}
\exp_args:NNV\KnowledgeConfigureTrigger[\l_tmpa_tl]{#2}{#3}}
{\keys_define:nn { knowledge~configuration~options }
- { #2 .code:n = {#3} }
+ { #2 .code:n = {#3}, #2 .default:V = \klparse_novalue_tl }
\keys_define:nn { knowledge~package~options }
{ #1 .code:n = {\tl_put_right:Nn\knowledge_configuration_pending_tl{,#2={##1}} }}
}
@@ -834,6 +876,9 @@
\bool_new:N\knowledge_configuration_quotation_bool
\KnowledgeConfigureBooleanOptionTF[\knowledge_configuration_quotation_bool]{quotation}{\klactivatequotation}{\kldeactivatequotation}
\KnowledgeConfigureOption{protect~quotation}{\kl_protect_environment_quotation:n{#1}}
+\bool_new:N\knowledge_configuration_diagnoseline_bool
+\bool_gset_true:N\knowledge_configuration_diagnoseline_bool
+\KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnoseline_bool]{diagnose~line}
\bool_new:N\knowledge_configuration_visibleAP_bool
\KnowledgeConfigureBooleanOption[\knowledge_configuration_visibleAP_bool]{visible~anchor~points}\KnowledgeConfigureBooleanOption[\knowledge_configuration_visibleAP_bool]{visible~AP}
\bool_new:N\knowledge_hyperlinks_active_bool
@@ -847,7 +892,7 @@
\KnowledgeConfigureTrigger{ fix~hyperref~twocolumn }
{\knowledgeFixHyperrefTwocolumn}
\KnowledgeConfigureTrigger{ notion }
- {\KnowledgeConfigureNotion}
+ {\KnowledgeConfigureNotion{notion}}
\KnowledgeConfigureTrigger{ protect~links }
{\kl_kl_nesting_incr:}
\KnowledgeConfigureTrigger{ unprotect~links }
@@ -951,6 +996,26 @@
\seq_new:N\scope_instances_stack_seq
\tl_new:N\scope_top_instance_tl
\tl_new:N\scope_top_area_tl
+\cs_new:Nn\scope_area_show:n{
+ \group_begin:
+ \scope_area_if_exist:nTF{#1}
+ { \tl_set:Nx\self{\scope_tl.area[#1]}
+ \tl_show:x
+ {Area~name:~\use:c{\self.name_tl},~
+ autoclose=\bool_if:cTF{\self.autoclose_bool}TF,~
+ recursive=\bool_if:cTF{\self.recursive_bool}TF,~
+ multiple=\bool_if:cTF{\self.multiple_bool}TF,~
+ scope=\bool_if:cTF{\self.scope_bool}TF,~
+ environment=\bool_if:cTF{\self.environment_bool}TF,~
+ forces={\use:c{\self.forces_tl}},~
+ accepts~knowledge=\bool_if:cTF{\self.accepts_knowledge_bool}TF,~
+ attracts~knowledge=\bool_if:cTF{\self.attracts_knowledge_bool}TF,~
+ accepts~labels=\bool_if:cTF{\self.labelizable_bool}TF.
+ }
+ }
+ {\knowledge_error:n{Unknown~area~`#1'~in~`\noexpand\scope_area_show:n'.}}
+ \group_end:
+}
\cs_new:Nn\scope_area_create:n
{\group_begin:
\tl_set:Nx\self{\scope_tl.area[#1]}
@@ -962,8 +1027,11 @@
\seq_gpush:cn{\self.category_seq}{all}
\seq_gpush:cn{\self.category_seq}{#1}
\bool_gset_false:c{\self.autoclose_bool}
+ \bool_gset_true:c{\self.environment_bool}
\bool_gset_true:c{\self.multiple_bool}
\bool_gset_true:c{\self.attractsknowledge_bool}
+ \bool_gset_true:c{\self.labelizable_bool}
+ \bool_gset_false:c{\self.scope_bool}
\bool_gset_true:c{\self.acceptsknowledge_bool}
\tl_gset:cn{\self.pushcode_tl}{}
\tl_gset:cn{\self.popcode_tl}{}
@@ -981,11 +1049,16 @@
}
\cs_new:Npn\scope_area_if_exist:nTF#1
{\tl_if_exist:cTF{\scope_tl.area[#1].name_tl}}
+\cs_new:Npn\scope_if_triggers_area:nTF#1{
+ \scope_area_if_exist:nTF{#1}
+ {\bool_if:cTF{\scope_tl.area[#1].environment_bool}
+ \use_i:nn
+ \use_ii:nn}
+ \use_ii:nn
+}
\cs_new:Npn\scope_area_if_in_scope:nTF#1
{\int_compare:nNnTF
{\use:c{\scope_tl.area[#1].nesting_int}}>0}
-\msg_new:nnn{scope}{area~exists}{Area~already~exists~'#1'.}
-\msg_new:nnn{scope}{area~not~exist}{Area~does~not~exist~'#1'.}
\NewDocumentCommand\ScopeConfigure{mm}
{\scope_area_set:nn{#1}{#2}}
\cs_new:Nn\scope_area_set:nn
@@ -1027,6 +1100,22 @@
occurrences / recursive .code:n = {
\bool_gset_true:c{\self.multiple_bool}
\bool_gset_true:c{\self.recursive_bool}},
+ scope .choice:,
+ scope / true .code:n = {
+ \bool_gset_true:c{\self.scope_bool}},
+ scope / false .code:n = {
+ \bool_gset_false:c{\self.scope_bool}},
+ environment .choice:,
+ environment / true .code:n = {
+ \bool_gset_true:c{\self.environment_bool}},
+ environment / false .code:n = {
+ \bool_gset_false:c{\self.environment_bool}},
+ environment .default:n = {true},
+ label .choice:,
+ label / none .code:n = {
+ \bool_gset_false:c{\self.labelizable_bool}},
+ label / accepts .code:n = {
+ \bool_gset_true:c{\self.labelizable_bool}},
knowledge .choice:,
knowledge / none .code:n = {
\bool_gset_false:c{\self.acceptsknowledge_bool}
@@ -1063,15 +1152,6 @@
{\tl_if_exist:cTF{\scopept_tl.label[#1].instance_tl}}
\tl_new:N\scope_pushed_area_tl
\tl_new:N\scope_popped_area_tl
-\msg_new:nnn{scope}{empty~pop}
- {Attempt~to~pop~an~empty~area~stack.}
-\msg_new:nnn{scope}{no~pushing~here}
- {Not~allowed~to~open~'\scope_pushed_area_tl'~here.~
- Current~stack~is~<\seq_use:Nn\scope_instances_stack_seq{::}>.}
-\msg_new:nnn{scope}{no~popping}
- {Not~allowed~to~close~'\scope_popped_area_tl'.}
-\msg_new:nnn{scope}{no~popping~here}
- {Not~allowed~to~close~'\scope_popped_area_tl'~here~(at~'\scope_top_area_tl').}
\cs_new:Nn\scope_area_pop:n {
\tl_gset:Nn\scope_popped_area_tl{#1}
\bool_if:cTF{\scope_tl.area[\scope_popped_area_tl].autoclose_bool}
@@ -1221,6 +1301,36 @@
{\scope_tl.area[\tl_use:c{\scope_tl.instance[##1].area_tl}].attractsknowledge_bool}
{\tl_set:Nn#1{##1}\seq_map_break:}{}}
}
+\cs_new:Nn\scope_get_labelizable_instance:N
+{\tl_set:Nn#1{base}
+ \seq_map_inline:Nn\scope_instances_stack_seq
+ {\bool_if:cTF
+ {\scope_tl.area[\tl_use:c{\scope_tl.instance[##1].area_tl}].labelizable_bool}
+ {\tl_set:Nn#1{##1}\seq_map_break:}{}}
+}
+\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_from_area:Nn{
+ \tl_set:Nn#1{}
+ \seq_map_inline:Nn\scope_instances_stack_seq
+ {\exp_args:Nxx\tl_if_eq:nnTF
+ {\csname \scope_tl.instance[##1].area_tl\endcsname}
+ {#2}
+ {\tl_set:Nn#1{##1}\seq_map_break:}
+ {}}
+ \tl_if_empty:NTF#1
+ {\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=}}
+}
\bool_new:N\scopept_map_break_bool
\cs_new:Nn\scopept_map_break:
{\bool_set_true:N\scopept_map_break_bool}
@@ -1246,8 +1356,9 @@
}
\NewDocumentCommand\scopeLabel{m}
{ \kl_hide_begin:
- \scope_get_attractive_instance:N\l_tmpb_tl
- \KAuxWriteX*{\exp_not:n{\KAuxScopeLabel{#1}}{\l_tmpb_tl}}
+ \scope_get_labelizable_instance:N\l_tmpb_tl
+ \KAuxWriteX*{\exp_not:n{\KAuxScopeLabel}{#1}{\l_tmpb_tl}}
+ \tl_gset:cx{\scopept_tl.label[#1].instance_tl}{\l_tmpb_tl}
\kl_hide_end:
\cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1}}
\let\label\scopeLabel
@@ -1264,20 +1375,45 @@
{\tl_if_exist:cTF{\scopept_tl.label[#1].instance_tl}}
\cs_new:Nn\scopept_label_instance_use:n
{\tl_use:c{\scopept_tl.label[#1].instance_tl}}
+\newcommand\knowledgeconfigureenvironment\KnowledgeConfigureEnvironment
+\NewDocumentCommand\KnowledgeConfigureEnvironment{t?t!mm}
+ {\clist_map_inline:nn{#3}{
+ \IfBooleanTF{#2}
+ {\scope_area_environment_new:nn{##1}{#4}}
+ {\cs_if_exist:cT{##1}
+ {\cs_if_exist:cT{end##1}
+ {\scope_area_environment_new:nn{##1}{#4}
+ \use_none:n}}
+ {\IfBooleanF{#1}
+ {\knowledge_error:n{Unknown~environment~`##1'~in~\KnowledgeConfigureEnvironment.}}}
+ }}}
+\newcommand\scope_activate_environment[2][environment]{
+ \scope_area_environment_new:nn
+ {#2}{category=#1}}
+\cs_new:Nn\scope_area_environment_new:nn
+ {\scope_area_set:nn{#1}{
+ parents = all,
+ autoclose = false,
+ environment = true,
+ occurrences = recursive,
+ knowledge = attracts,
+ category = environment,
+ #2
+ }}
\NewDocumentCommand\ScopeHackEnvironments{}
{ %\ScopeActivate
\scope_area_push:n{document}
\kutils_secure_latex_command:N\begin
\global\let\SUPERbegin\begin
\global\def\begin##1
- {\scope_area_if_exist:nTF{##1}
+ {\scope_if_triggers_area:nTF{##1}
{\scope_area_push:n{##1}}{}
\SUPERbegin{##1}}
\kutils_secure_latex_command:N\end
\global\let\SUPERend\end
\global\def\end##1
{\SUPERend{##1}
- \scope_area_if_exist:nTF{##1}
+ \scope_if_triggers_area:nTF{##1}
{\scope_area_pop:n{##1}}
{}}
\kutils_secure_latex_command:N\label
@@ -1288,40 +1424,10 @@
\cs_gset_eq:NN\ScopeActivate\relax
}
\AtBeginDocument{\ScopeActivate}
-\scope_area_set:nn{knowledge~context~internal}
-{
- occurrences = recursive,
- autoclose = false,
- parents= {base,all},
- knowledge=attracts
-}
-\scope_area_set:nn{knowledge~import~internal}
-{
- occurrences = recursive,
- autoclose = false,
- parents= {base,all},
- knowledge = accepts
-}
-\NewDocumentEnvironment{knowledge~import}{m}
- {\ScopeActivate\scope_area_push:n{knowledge~import~internal}
- \clist_map_inline:nn{#1}{\knowledgeimport{##1}}}
- {\scope_area_pop:n{knowledge~import~internal}}
-\NewDocumentEnvironment{knowledge~context}{m}
- {\ScopeActivate\scope_area_push:n{knowledge~context~internal}
- \scopeLabel{#1}}
- {\scope_area_pop:n{knowledge~context~internal}}
-\NewDocumentCommand\knowledgescopingenvironment{>{\SplitList{,}} m}
- { \cs_set:Nn\l_tmpa_cs:n
- {\scope_area_set:nn{##1}
- {autoclose=false,
- occurrences=recursive,
- knowledge=attracts,
- parents=all}}
- \ProcessList{#1}\l_tmpa_cs:n
-}
\AtBeginDocument{\ScopeHackEnvironments}
-\AtEndDocument{\scope_area_pop:n{document}}
-\cs_new:Nn\knowledge_scope_default:{
+ \scope_area_set:nn{document,base,body} {
+ environment=false
+ }
\scope_area_set:nn{base}
{occurrences = once,
autoclose = false}
@@ -1343,27 +1449,72 @@
\newenvironment{scope}
{\mode_if_preamble:TF{\scope_area_push:n{scope}}{}}
{\mode_if_preamble:TF{\scope_area_pop:n{scope}}{}}
- \knowledgescopingenvironment{scope}
+ \knowledgeconfigureenvironment{scope}{}
+\scope_area_set:nn{knowledge~context~internal}
+{
+ occurrences = recursive,
+ autoclose = false,
+ parents= {base,all},
+ knowledge=attracts
+}
+\scope_area_set:nn{knowledge~import~internal}
+{
+ occurrences = recursive,
+ autoclose = false,
+ parents= {base,all},
+ knowledge = accepts
}
-\knowledge_scope_default:
+\NewDocumentEnvironment{knowledge~import}{m}
+ {\ScopeActivate\scope_area_push:n{knowledge~import~internal}
+ \clist_map_inline:nn{#1}{\knowledgeimport{##1}}}
+ {\scope_area_pop:n{knowledge~import~internal}}
+\NewDocumentEnvironment{knowledge~context}{m}
+ {\ScopeActivate\scope_area_push:n{knowledge~context~internal}
+ \scopeLabel{#1}}
+ {\scope_area_pop:n{knowledge~context~internal}}
\KAuxBefore{\KAuxProcess{init}}
\KAuxInit{}
\KAuxAfter{\KnowledgeDiagnoseOutput}
\iow_new:N\knowledge_diagnosefile_iow
\cs_new:Nn\knowledge_diagnose:n
{\iow_now:Nn\knowledge_diagnosefile_iow{#1}}
-\cs_generate_variant:Nn\knowledge_diagnose:n{x}
+\cs_generate_variant:Nn\knowledge_diagnose:n{x,V}
+
+\cs_new:Nn\knowledge_diagnose_reset_line:
+ {\tl_gset:Nn\knowledge_diagnose_lastline_tl{...}}
+\knowledge_diagnose_reset_line:
+
+\cs_new:Nn\knowledge_diagnose_line:
+ {\bool_if:NT\knowledge_configuration_diagnoseline_bool
+ {\tl_set:Nx\g_tmpa_tl
+ {\c_percent_str\space\kauxCurrentFile : \kauxCurrentLine}
+ \tl_if_eq:NNTF\g_tmpa_tl\knowledge_diagnose_lastline_tl
+ {}
+ {\tl_gset_eq:NN\knowledge_diagnose_lastline_tl\g_tmpa_tl
+ \knowledge_diagnose:V\g_tmpa_tl}}}
+
+\msg_new:nnn{knowledge}{unknown~knowledge}
+ {Some~knowledge~are~not~defined.~See~the~'.diagnose'~file~for~more~information.}
+\msg_new:nnn{knowledge}{autoref~introduced~twice}
+ {Some~knowledge~is~introduced~twice.~See~the~'.diagnose'~file~for~more~information.}
+\msg_new:nnn{knowledge}{autoref~not~introduced}
+ {Some~knowledge~is~used~but~not~introduced.~See~the~'.diagnose'~file~for~more~information.}
+\msg_new:nnn{knowledge}{scope~unknown}
+ {Some~label~is~used~but~not~defined.~See~the~'.diagnose'~file~for~more~information.}
\NewDocumentCommand\KnowledgeDiagnoseOutput{}{
\iow_open:Nn\knowledge_diagnosefile_iow{\c_sys_jobname_str.diagnose}
% compute first the list of warnings and important information
- \KAuxProcess{diagnose~digest}
+ %
+ \knowledge_diagnose_reset_line:
+ \KAuxProcess{diagnose-digest}
%
\knowledge_diagnose:n{***********}
\knowledge_diagnose:n{*~Summary~*}
\knowledge_diagnose:n{***********}
\knowledge_diagnose:n{}
\knowledge_diagnose:x{\int_use:N\kl_digest_unknownknowledge_int\space undefined~knowledge(s).}
+ %\knowledge_diagnose:x{\int_use:N\kl_digest_unknownlabel_int\space label(s)~are~used~as~scopes~but~not~introduced.}
\knowledge_diagnose:x{\int_use:N\kl_digest_autoreftwiceintro_int\space autoreference(s)~are~introduced~twice.}
\knowledge_diagnose:x{\int_use:N\kl_digest_autorefnointro_int\space autoreference(s)~are~used~but~not~introduced.}
\knowledge_diagnose:n{}
@@ -1377,27 +1528,45 @@
\knowledge_diagnose:n{*~Undefined~knowledges~*}
\knowledge_diagnose:n{************************}
\knowledge_diagnose:n{}
+ %
+ \knowledge_diagnose_reset_line:
\KAuxProcess{diagnose-unknown-suggest}
+ %
+ \knowledge_diagnose:n{}
\knowledge_diagnose:n{}
- \knowledge_diagnose:n{}}
+ %
+ \msg_warning:nn{knowledge}{unknown~knowledge}
+ }
%
\int_compare:nNnT\kl_digest_autoreftwiceintro_int>0{
\knowledge_diagnose:n{****************************}
- \knowledge_diagnose:n{*~Autoref~introduced~twice~*}
+ \knowledge_diagnose:n{*~autoref-introduced-twice~*}
\knowledge_diagnose:n{****************************}
\knowledge_diagnose:n{}
- \KAuxProcess{autoref~introduced~twice}
+ %
+ \knowledge_diagnose_reset_line:
+ \KAuxProcess{autoref-introduced-twice}
+ %
+ \knowledge_diagnose:n{}
\knowledge_diagnose:n{}
- \knowledge_diagnose:n{}}
+ %
+ \msg_warning:nn{knowledge}{autoref~introduced~twice}
+ }
%
\int_compare:nNnT\kl_digest_autorefnointro_int>0{
\knowledge_diagnose:n{******************************}
\knowledge_diagnose:n{*~Autoref~used~without~intro~*}
\knowledge_diagnose:n{******************************}
\knowledge_diagnose:n{}
- \KAuxProcess{autoref~not~introduced}
+ %
+ \knowledge_diagnose_reset_line:
+ \KAuxProcess{autoref-not-introduced}
+ %
\knowledge_diagnose:n{}
- \knowledge_diagnose:n{}}
+ \knowledge_diagnose:n{}
+ %
+ \msg_warning:nn{knowledge}{autoref~not~introduced}
+ }
%
\iffalse
\knowledge_diagnose:n{***********************}
@@ -1413,13 +1582,18 @@
\makeatother
\cell_new_type:nnn{knowledge}{nnnn}{KL@#2@#3@\detokenize{#4}_#1}
\cell_new_type:nnn{knowledge}{nnn}{\knowledge_id:nnnn{}{#1}{#2}{#3}}
-\cs_generate_variant:Nn\knowledge_id:nnn{nnV,nVV,nVn}
+\cs_generate_variant:Nn\knowledge_id:nnn{nnV,nVV,nVn,VVV}
\cs_generate_variant:Nn\knowledge_at:Nnnn{NnnV}
\cs_new:Npn\knowledge_at:c{\exp_args:Nc\knowledge_at:N}
\cs_new:Nn\knowledge_sets_to:nnn
{\cs_set:Nx\knowledge_at:N
{##1\exp_not:c{\knowledge_id:nnn{#1}{#2}{#3}}}}
\tuple_new:n{ktuple}
+\cs_new:Npn\knowledge_knowledge_if_exist:nnnTF#1#2#3{
+ \exp_args:Nc\ktuple_if_exist:NTF{\knowledge_id:nnn{#1}{#2}{#3}}
+}
+\cs_generate_variant:Nn
+ \knowledge_knowledge_if_exist:nnnTF{VVVTF}
\NewDocumentCommand\NewKnowledgeParamBool{smm}{
\ktuple_new_bool_index:n{#2}
\use:c{ktuple_#2_expands_to:TF}
@@ -1486,13 +1660,13 @@
##1 .code:n = {
\msg_error:nnnn{ knowledge }{ package~required }{##1}{#2}}
}}}
-\msg_new:nnn{ knowledge }{ package~required }
- {In~order~to~use~directive~'#1',~please~load~package~or~use~option~'#2'.}
\tl_new:N\knowledge_current_instance_tl
\tl_gset:Nn\knowledge_current_instance_tl{base}
\seq_new:N\knowledge_visible_instances_seq
\cs_new:Nn\knowledge_push_visible_instance:n
{\seq_gpush:Nn\knowledge_visible_instances_seq{#1}}
+\cs_new:Nn\knowledge_lpush_visible_instance:n
+ {\seq_push:Nn\knowledge_visible_instances_seq{#1}}
\cs_new:Npn\knowledge_pop_visible_instance:
{\seq_gpop:NN\knowledge_visible_instances_seq\g_tmpa_tl}
\cs_new:Nn\knowledge_pop_visible_instances_to:n
@@ -1511,11 +1685,9 @@
{\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_if_exist:NTF\knowledge_track_instance:n{}
- {\cs_new:Nn\knowledge_track_instance:n{base}}
\keys_define:nn { knowledge~directives } {
namespace .code:n = { \tl_set:Nn\knowledge_knowledge_namespace_tl{#1} },
force .choice:,
@@ -1533,13 +1705,14 @@
instance .code:n =
{ \tl_set:Nn\knowledge_knowledge_instance_tl{#1} },
scope .code:n =
- { \tl_set:Nx\knowledge_knowledge_instance_tl{\knowledge_track_instance:n{#1}}},
+ { \knowledge_scope_track_instance:Nn\knowledge_knowledge_instance_tl{#1} },
synonym .code:n =
- { \exp_args:Nnx\keys_set:nn { knowledge~directives }
- {link={\exp_not:o\knowledge_knowledge_synonym_tl}}}
+ { \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}}}
}
-\msg_new:nnn{ knowledge }{ knowledge~exists }
- { The~knowledge~'#1'~in~scope~'#2'~(namespace~'#3')~already~exists. }
\NewKAuxCommand\KAuxKnowledge{mmmm}
{Package~knowledge:~Declares~a~knowledge.~
Takes~the~{namespace}{instance}{knowledge}{directives}.}
@@ -1553,7 +1726,7 @@
\knowledge_at:N\ktuple_if_exist:NTF
{\bool_if:NTF\knowledge_knowledgestyle_bool
{\knowledge_at:N\ktuple_gclear:N}
- {\tl_show:n{knowledge~'#3'~(namespace=#1,~scope=#2)~is~redefined.}}}
+ {\knowledge_warning:n{knowledge~'#3'~(namespace=#1,~scope=#2)~is~redefined.}}}
{\knowledge_at:N\ktuple_new:N}
\keys_set:nn { knowledgenow~directives } { #4 }
}
@@ -1572,20 +1745,25 @@
\exp_not:n{\knowledge_knowledge_process:nn{#1}}
{\exp_not:V\kl_knowledgedefault_tl,\exp_not:n{#3}}}
%
- % if synonym, then the synonym name is unchanged
\bool_if:NF\knowledge_knowledge_is_synonym_bool
- {\tl_gset:Nn\knowledge_knowledge_synonym_tl{#1}}
+ {\tl_gset:Nn\knowledge_knowledge_synonym_tl{#1}
+ \tl_gset_eq:NN\knowledge_knowledge_synonyminstance_tl
+ \knowledge_knowledge_instance_tl}
%
\IfNoValueTF{#2}{}{
\cs_set:Nn\l_tmpa_cs:n
- {\knowledge_knowledge_process:nn{##1}{link={#1}}}
+ {\exp_args:Nnx\knowledge_knowledge_process:nn{##1}{synonym}}
\ProcessList{#2}\l_tmpa_cs:n
}
+ %
\group_end:
\kl_hide_end:
}
+\bool_new:N\knowledge_knowledge_now_bool
\bool_new:N\knowledge_knowledge_is_synonym_bool
\tl_new:N\knowledge_knowledge_synonym_tl
+\tl_new:N\knowledge_knowledge_synonyminstance_tl
+\tl_gset:Nn\knowledge_knowledge_synonyminstance_tl{}
\bool_new:N\knowledge_knowledgestyle_bool
\NewDocumentCommand\knowledgestyle{ s m m }
{ \kl_hide_begin:
@@ -1593,6 +1771,9 @@
\tl_set:Nn\knowledge_namespace_tl{style}
%
\bool_set_true:N\knowledge_knowledgestyle_bool
+ \IfBooleanTF{#1}
+ {\bool_set_true:N\knowledge_knowledgestyle_override_bool}
+ {\bool_set_false:N\knowledge_knowledgestyle_override_bool}
%
\knowledge_knowledge_process:nn{#2}{#3}
\group_end:
@@ -1604,6 +1785,7 @@
\bool_set_false:N\knowledge_knowledge_force_bool
\bool_set_false:N\knowledge_knowledge_export_bool
%
+ %
\tl_set:Nn\knowledge_key_tl{#1}
%
\tl_set_eq:NN\knowledge_knowledge_namespace_tl\knowledge_namespace_tl
@@ -1616,6 +1798,7 @@
\mode_if_preamble:TF
{\bool_set_true:N\knowledge_knowledge_now_bool}
{}
+ %
\bool_if:NTF\knowledge_knowledge_now_bool
{\use:x{
\exp_not:N\knowledge_set_now:nnnn
@@ -1623,14 +1806,15 @@
{\knowledge_knowledge_instance_tl}
{\exp_not:V\knowledge_key_tl}
{\exp_not:V\knowledge_directives_tl}}
- } {
+ }{
\KAuxWriteX*{
\exp_not:N\KAuxKnowledge
{\knowledge_knowledge_namespace_tl}
{\knowledge_knowledge_instance_tl}
{\exp_not:V\knowledge_key_tl}
{\exp_not:V\knowledge_directives_tl}}
- }
+ }
+ %
\bool_if:NT\knowledge_knowledge_export_bool
{\KAuxWriteX*{
\exp_not:N\KAuxExport
@@ -1664,35 +1848,75 @@
{\tl_set:Nn\kl_knowledgedefault_tl{#2}}
\kl_hide_end:
}
-\int_const:Nn\knowledge_kl_max_recursion_int{40}
-\int_new:N\knowledge_kl_recursion_int
-\cs_new:Nn\kl_base:nn{
- \tl_set:Nn\knowledge_kl_text_tl{#2}
+\NewDocumentCommand\kl{d() o d() m}{
\IfNoValueTF{#1}
- {\tl_set:Nn\knowledge_kl_base_key_tl{#2}}
- {\tl_set:Nn\knowledge_kl_base_key_tl{#1}}
- %
- \tl_set_eq:NN\knowledge_kl_key_tl\knowledge_kl_base_key_tl
- %
- \int_set_eq:NN\knowledge_kl_recursion_int\knowledge_kl_max_recursion_int
- %
- \knowledge_kl_find:
+ {\IfNoValueTF{#3}
+ {\IfNoValueTF{#2}
+ {\knowledge_klTKS:nnn{#4}{#4}{}}
+ {\knowledge_klTKS:nnn{#4}{#2}{}}}
+ {\IfNoValueTF{#2}
+ {\knowledge_klTKS:nnn{#4}{#4}{#3}}
+ {\knowledge_klTKS:nnn{#4}{#2}{#3}}}}
+ {\IfNoValueTF{#2}
+ {\knowledge_klTKS:nnn{#4}{#4}{#1}}
+ {\knowledge_klTKS:nnn{#4}{#2}{#1}}}
+}
+\NewDocumentCommand\klTKS{}{\knowledge_klTKS:nnn}
+\cs_new:Nn\knowledge_klTKS:nnn{
+ \group_begin:
+ \knowledge_kl_init:
+ \cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init:
+ \tl_set:Nn\knowledge_kl_linkscope_tl{#3}
+ \tl_set:Nn\knowledge_kl_linkinstance_tl{}
+ \tl_set:Nn\knowledge_kl_text_tl{#1}
+ \tl_set:Nn\knowledge_kl_base_key_tl{#2}
+ \tl_set_eq:NN\knowledge_kl_key_tl\knowledge_kl_base_key_tl
+ \int_set_eq:NN\knowledge_kl_recursion_int\knowledge_kl_max_recursion_int
+ \knowledge_kl_find:
+ \group_end:
+ \knowledge_display_sequence:
}
-\cs_new:Nn\knowledge_kl_find:
-{
+\int_const:Nn\knowledge_kl_max_recursion_int{40}
+\int_new:N\knowledge_kl_recursion_int
+\cs_set:Nn\knowledge_kl_find:{
+ \tl_if_empty:NTF\knowledge_kl_linkinstance_tl
+ {\tl_if_empty:NTF\knowledge_kl_linkscope_tl
+ \knowledge_kl_find_withoutscope:
+ \knowledge_kl_find_withscope:}
+ \knowledge_kl_find_withinstance:
+}
+\cs_new:Nn\knowledge_kl_find_withinstance:{
+ \knowledge_knowledge_if_exist:VVVTF
+ \knowledge_kl_namespace_tl
+ \knowledge_kl_linkinstance_tl
+ \knowledge_kl_key_tl
+ {\knowledge_kl_exec:nnV
+ \knowledge_kl_namespace_tl
+ \knowledge_kl_linkinstance_tl
+ \knowledge_kl_key_tl}
+ { \knowledge_kl_error_unknown_in_scope: }
+}
+\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_linkinstance_tl
+ {\scopept_label_instance_use:n{\knowledge_kl_linkscope_tl}}
+ \knowledge_kl_find_withinstance: }
+ { \knowledge_kl_error_label_unknown: }
+}
+\cs_new:Nn\knowledge_kl_find_withoutscope:{
\int_decr:N\knowledge_kl_recursion_int
\tl_clear:N\knowledge_kl_link_tl
\tl_clear:N\knowledge_kl_style_tl
\tl_clear:N\knowledge_kl_intro_style_tl
\int_compare:nNnTF\knowledge_kl_recursion_int=0
- {\knowledge_kl_error_recursion:}
+ \knowledge_kl_error_recursion:
{\knowledge_kl_find_in_scope:VNTF
- \knowledge_kl_key_tl\knowledge_kl_instance_tl
- {\exp_args:Nc\knowledge_kl_exec:N
- {\knowledge_id:nnV
+ \knowledge_kl_key_tl\knowledge_kl_linkinstance_tl
+ {\knowledge_kl_exec:nnV
\knowledge_kl_namespace_tl
- \knowledge_kl_instance_tl
- \knowledge_kl_key_tl}}
+ \knowledge_kl_linkinstance_tl
+ \knowledge_kl_key_tl}
{\knowledge_kl_error_unknown:}
}
}
@@ -1721,43 +1945,63 @@
\seq_map_break:}{}}
\cs_generate_variant:Nn\knowledge_kl_find_in_scope:nnNTF{nVNTF}
\cs_generate_variant:Nn\knowledge_kl_find_in_scope:nNTF{VNTF}
+\cs_new:Nn\knowledge_kl_exec:nnn{
+ \exp_args:NNc\tl_set:Nn\knowledge_kl_resource_tl
+ {\knowledge_id:nnn{#1}{#2}{#3}}
+ %
+ \tl_set:Nn\knowledge_kl_link_tl{}
+ \tl_set:Nn\knowledge_kl_linkscope_tl{}
+ \tl_set:Nn\knowledge_kl_linkinstance_tl{}
+ %
+ \knowledge_kl_resource_tl
+ %
+ \tl_if_empty:xTF\knowledge_kl_used_style_tl
+ {}
+ {\knowledge_kl_use_style:x
+ {\knowledge_kl_used_style_tl}}
+ %
+ \expandafter\knowledge_kl_update:N\knowledge_kl_resource_tl
+ %
+ %\knowledge_kl_exec_to_kaux:
+ %
+ \tl_if_exist_ne:NTF\knowledge_kl_linkscope_tl{
+ \tl_if_exist_ne:NTF\knowledge_kl_link_tl{}{
+ \tl_set_eq:NN\knowledge_kl_link_tl
+ \knowledge_kl_key_tl
+ }}{}
+ %
+ \tl_if_exist_ne:NTF\knowledge_kl_link_tl{
+ \tl_set_eq:NN
+ \knowledge_kl_key_tl
+ \knowledge_kl_link_tl
+ \knowledge_kl_find:
+ }{
+ \knowledge_kl_display_code:}
+}
+\cs_generate_variant:Nn\knowledge_kl_exec:nnn{nnV}
\cs_new:Nn\knowledge_kl_use_style:n{
\knowledge_kl_find_in_scope:nnNTF
{style}
{#1}
\l_tmpa_tl
{\use:c{\knowledge_id:nVn{style}\l_tmpa_tl{#1}}}
- {\tl_show:n{ERROR-UNKNOWN-STYLE:~#1}}
+ {\knowledge_error:n{Unknown~style~`#1'}}
}
\cs_generate_variant:Nn\knowledge_kl_use_style:n {x}
-
-\cs_new:Nn\knowledge_kl_exec:N{
- #1
- \tl_set:Nn\knowledge_kl_resource_tl{#1}
- \tl_if_empty:xTF\knowledge_kl_used_style_tl
- {}
- {\knowledge_kl_use_style:x
- {\knowledge_kl_used_style_tl}}
- \tl_if_exist_ne:NTF\knowledge_kl_link_tl{
- \knowledge_kl_update:N#1
- \tl_set_eq:NN
- \knowledge_kl_key_tl
- \knowledge_kl_link_tl
- \tl_set:Nn\knowledge_kl_link_tl{}
- \knowledge_kl_find:
- }{
- \knowledge_kl_update:N#1
- \knowledge_kl_display_code:
-}}
\NewKAuxCommand\KAuxErrorKnowledgeUnknown{mmmm}
- {Package~'knowledge':~A~knowledge~is~not~defined.~
- {namespace}{scope}{undefined~knowledge}{base~knowledge}}
+ {Package~'knowledge:~A~knowledge~is~not~defined.~
+ {namespace}{scope/empty}{undefined~knowledge}{base~knowledge}}
+ {}
+\NewKAuxCommand\KAuxErrorLabelUnknown{m}
+ {Package~'knowledge:~A~label~is~not~defined.~
+ {label}}
{}
-
\DeclareKAuxPhaseCommand\KAuxErrorKnowledgeUnknown{diagnose-unknown-suggest}
- {\knowledge_diagnose:n
- {\knowledge{#3}{}}}
-
+ {\knowledge_diagnose_line:
+ \tl_if_empty:nTF{#2}
+ {\knowledge_diagnose:n{\knowledge{#3}{}}}
+ {\knowledge_diagnose:n{\knowledge{#3}{scope={#2}}}}
+ }
\cs_new:Nn\knowledge_kl_error_unknown:
{\KAuxWriteX{
\KAuxErrorKnowledgeUnknown
@@ -1766,47 +2010,64 @@
{\exp_args:NV\detokenize\knowledge_kl_key_tl}
{\exp_args:NV\detokenize\knowledge_kl_base_key_tl}
}
- \knowledge_kl_use_style:n{unknown}
- \knowledge_set_now:nnVn
- {default}{base}
- \knowledge_kl_key_tl
- {style={unknown~(cont)}}
- \msg_warning:nnxxx{ knowledge }{ knowledge~unknown }
+ \IfKnowledgePaperModeF{
+ \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{~|~}}}
+ \knowledge_kl_use_style:n{unknown}
+ \knowledge_set_now:nnVn
+ {default}{base}
+ \knowledge_kl_key_tl
+ {style={unknown}}
\knowledge_kl_display_code:
}
-
-\msg_new:nnn{ knowledge }{ knowledge~unknown }
- {The~knowledge~'#1'~(namespace~'#2')~could~not~be~found~in~scopes~<~#3~>.}
-\NewKAuxCommand\KAuxErrorKnowledgeRecursive{mmmm}
- {Package~'knowledge':~A~knowledge~has~recursive~definition.~
- {namespace}{scope}{undefined~knowledge}{base~knowledge}}
- {}
-
-\msg_new:nnn{ knowledge }{ knowledge~recursion }
- { The~knowledges~are~probably~cyclic,~starting~from~'#1'~(namespace~'#2'),~
- currently~at~'#3'.}
-
-\cs_new:Nn\knowledge_kl_error_recursion: {
- \msg_error:nnxxx{ knowledge }{ knowledge~recursion }
- {\exp_not:V\knowledge_kl_base_key_tl}
- {\exp_not:V\knowledge_kl_namespace_tl}
- {\exp_not:V\knowledge_kl_key_tl}
- \knowledge_kl_error_display:n{recursive~knowledge}
+\cs_new:Nn\knowledge_kl_error_unknown_in_scope:
+ {\KAuxWriteX{
+ \KAuxErrorKnowledgeUnknown
+ {\knowledge_kl_namespace_tl}
+ {\knowledge_kl_linkscope_tl}
+ {\exp_args:NV\detokenize\knowledge_kl_key_tl}
+ {\exp_args:NV\detokenize\knowledge_kl_base_key_tl}
+ }
+ \IfKnowledgePaperModeF{
+ \msg_warning:nnxxx{ knowledge }{ knowledge~unknown~in~scope }
+ {\exp_not:V\knowledge_kl_key_tl}
+ {\exp_not:V\knowledge_kl_namespace_tl}
+ {\knowledge_kl_linkscope_tl}}
+ \knowledge_kl_use_style:n{unknown}
+ \knowledge_set_now:nnVn
+ {default}{base}
+ \knowledge_kl_key_tl
+ {style={unknown}}
+ \knowledge_kl_display_code:
+}
+\cs_new:Nn\knowledge_kl_error_label_unknown:{
+ \KAuxWriteX{
+ \KAuxErrorKnowledgeUnknown
+ {\knowledge_kl_namespace_tl}
+ {\knowledge_kl_linkscope_tl}
+ {\exp_args:NV\detokenize\knowledge_kl_key_tl}
+ {\exp_args:NV\detokenize\knowledge_kl_base_key_tl}
+ }
+ \knowledge_kl_use_style:n{unknown}
+ \IfKnowledgePaperModeF{
+ \msg_warning:nnxx{ knowledge }{ knowledge~unknown~label }
+ {\exp_not:V\knowledge_kl_key_tl}
+ {\knowledge_kl_linkscope_tl}}
+ \knowledge_kl_display_code:
}
-
\cs_new:Nn\knowledge_kl_error_display:n
{\textcolor{orange}{\exp_args:NV\detokenize\knowledge_kl_text_tl}}
\NewDocumentCommand\intro{s}{
- \cs_gset_eq:NN\knowledge_kl_init:\knowledge_intro_init:
- \IfBooleanF{#1}\kl
-}
+ \kl_activate_intro:\IfBooleanF{#1}\kl}
\NewDocumentCommand\reintro{s}{
- \cs_gset_eq:NN\knowledge_kl_init:\knowledge_reintro_init:
- \IfBooleanF{#1}\kl
-}
+ \kl_activate_reintro:\IfBooleanF{#1}\kl}
+
+\cs_new:Nn\kl_activate_intro:
+ {\cs_gset_eq:NN\knowledge_kl_init:\knowledge_intro_init:}
+\cs_new:Nn\kl_activate_reintro:
+ {\cs_gset_eq:NN\knowledge_kl_init:\knowledge_reintro_init:}
\NewDocumentCommand\phantomintro{m}{
\cs_gset_eq:NN\knowledge_kl_init:\knowledge_phantomintro_init:
\kl[{#1}]{}
@@ -1870,15 +2131,6 @@
\cs_gset:Nn\knowledge_defaultkl_update:N
{\ktuple_countuse_gincr:N#1}
\tl_set:Nn\knowledge_defaultkl_namespace_tl{default}
-\NewDocumentCommand\kl{om}{\kl_kl_inner:nn{#1}{#2}}
-\cs_new:Nn\kl_kl_inner:nn
-{\group_begin:
- \knowledge_kl_init:
- \cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init:
- \kl_base:nn{#1}{#2}
- \group_end:
- \knowledge_display_sequence:
-}
\tl_set:Nn\knowledge_variablekl_namespace_tl{variable}
\bool_new:N\kl_already_met_bool
\ktuple_new_bool_index:n{already_met_bool}
@@ -1947,6 +2199,8 @@
\NewKnowledgeParamBool*{uppercase}\kl_uppercase_bool
\NewKnowledgeParamTl*{text}\kowledge_kl_forced_text_tl
\NewKnowledgeParamTl*{link}\knowledge_kl_link_tl
+\NewKnowledgeParamTl*{link~scope}\knowledge_kl_linkscope_tl
+\NewKnowledgeParamTl*{link~instance}\knowledge_kl_linkinstance_tl
\NewKnowledgeParamTl*{wrap}\knowledge_kl_wrap_tl
\NewKnowledgeParamTl*{style}\knowledge_kl_style_tl
\NewKnowledgeParamTl*{intro~style}\knowledge_kl_intro_style_tl
@@ -1955,6 +2209,9 @@
\ktuple_countuse_expands_to:n{}
\ktuple_new_int_index:n{countintro}
\ktuple_countintro_expands_to:n{}
+\keys_define:nn{ knowledge~directives }{
+ now .code:n = { \bool_set_true:N\knowledge_knowledge_now_bool }
+}
\int_new:N\knowledge_autoref_count
\keys_define:nn{ knowledge~directives }{
@@ -1990,11 +2247,12 @@ autoref .code:n =
\int_new:N\kl_digest_autoreftwiceintro_int
\int_new:N\kl_digest_autorefunused_int
\int_new:N\kl_digest_unknownknowledge_int
+\int_new:N\kl_digest_unknownlabel_int
-\DeclareKAuxPhaseCommand\KAuxErrorKnowledgeUnknown{diagnose~digest}
+\DeclareKAuxPhaseCommand\KAuxErrorKnowledgeUnknown{diagnose-digest}
{\int_gincr:N\kl_digest_unknownknowledge_int}
-\DeclareKAuxPhaseCommand\KAuxAutoref{diagnose~digest}
+\DeclareKAuxPhaseCommand\KAuxAutoref{diagnose-digest}
{\group_begin:
\knowledge_sets_to:nnn{#1}{#2}{#3}
\knowledge_at:N\ktuple_countuse_get_int:NN\kl_countuse_int
@@ -2009,23 +2267,28 @@ autoref .code:n =
{\int_gincr:N\kl_digest_autoreftwiceintro_int}
\group_end:}
-\DeclareKAuxPhaseCommand\KAuxAutoref{autoref~not~introduced}
+\DeclareKAuxPhaseCommand\KAuxAutoref{autoref-not-introduced}
{\group_begin:
\knowledge_sets_to:nnn{#1}{#2}{#3}
\knowledge_at:N\ktuple_countuse_get_int:NN\kl_countuse_int
\knowledge_at:N\ktuple_countintro_get_int:NN\kl_countintro_int
\int_compare:nNnT\kl_countuse_int>0
{\int_compare:nNnT\kl_countintro_int=0
- {\knowledge_diagnose:n{\nointro{#1}{#2}{#3}}}}
+ {\knowledge_diagnose_line:
+ \knowledge_diagnose:n{\nointro{#1}{#2}{#3}}}}
\group_end:}
-\DeclareKAuxPhaseCommand\KAuxAutoref{autoref~introduced~twice}
+\DeclareKAuxPhaseCommand\KAuxAutoref{autoref-introduced-twice}
{\group_begin:
\knowledge_sets_to:nnn{#1}{#2}{#3}
\knowledge_at:N\ktuple_countuse_get_int:NN\kl_countuse_int
\knowledge_at:N\ktuple_countintro_get_int:NN\kl_countintro_int
\int_compare:nNnT\kl_countintro_int>1
- {\knowledge_diagnose:n{{#1}{#2}{#3}}}
+ {\knowledge_diagnose_line:
+ \knowledge_diagnose:n{{#1}{#2}{#3}}}
\group_end:}
+\NewKAuxCommand\KAuxUseKnowledge{mmm}
+ {Package~knowledge:~Identifies~the~use~of~some~knowledge.~
+ Arguments~{namespace}{instance}{knowledge}.}
\cs_new:Nn\knowledge_kl_display_sequence:n
{\knowledge_kl_display_sequence:w#1\display_end:}
\cs_new:Npn\knowledge_kl_display_sequence:w#1#2\display_end:
@@ -2065,13 +2328,10 @@ autoref .code:n =
\knowledge_defaultkl_display_code_text:}}
}
\cs_new:Nn\knowledge_kl_display_code_index:n{#1}
-
\cs_new:Nn\knowledge_defaultkl_display_code_fbox:n
{\bool_if:NTF\kl_fbox_bool{\exp_not:N\fbox{#1}}{#1}}
-
\cs_new:Npn\knowledge_kl_display_code_preprocess:
{}
-
\cs_new:Nn\knowledge_defaultkl_display_code_ensuremath:n
{\bool_if:NTF\kl_ensuremath_bool{\exp_not:N\ensuremath}\use:n{#1}}
\cs_new:Nn\knowledge_defaultkl_display_code_ensuretext:n
@@ -2152,7 +2412,6 @@ autoref .code:n =
\cs_new:Nn\knowledge_defaultkl_code_wrap:n{
\tl_if_exist:NTF\knowledge_kl_wrap_tl
{\exp_not:V\knowledge_kl_wrap_tl{#1}}{#1}}
-
\cs_new:Nn\knowledge_defaultkl_display_code_text:{
\knowledge_defaultkl_code_wrap:n{
\tl_if_exist:NTF\kowledge_kl_forced_text_tl
@@ -2214,6 +2473,30 @@ autoref .code:n =
\hbox_overlap_left:n
{\knowledge_AP_mark:\hspace{1em}}
}
+\cs_new:Nn\knowledge_kl_TKS:nnn{
+ \group_begin:
+ \knowledge_warning:n{#1/#2/#3}
+ \knowledge_kl_init:
+ \cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init:
+
+ \scopept_label_instance_if_exist:nTF{#3}
+ { \exp_args:Nx\knowledge_lpush_visible_instance:n
+ {\scopept_label_instance_use:n{#3}}
+ \kl_base:nn{#2}{#1}
+ }
+ { \tl_set:Nn\knowledge_kl_text_tl{#1}
+ \knowledge_kl_error_label_unknown:
+ \knowledge_warning:n
+ {Unknown~label~in~scope=`#3'.~Possibly~rerun~latex.}
+ }
+ \group_end:
+ \exp_args:No\knowledge_warning:n\knowledge_display_sequence:
+\knowledge_warning:n{before}
+ \knowledge_display_sequence:
+\knowledge_warning:n{after}
+ %\tl_show:n{\fskljkqlffk}
+}
+\NewDocumentCommand\klInnerTKSnnn{}\knowledge_kl_TKS:nnn
\ExplSyntaxOff
\def\makequotationactive
{\catcode`"13\relax}
@@ -2221,6 +2504,7 @@ autoref .code:n =
{\catcode`"12\relax}
\let\quotationmark"
+
\ExplSyntaxOn
\makequotationactive
\edef\klactivequotationmark#1"{
@@ -2228,15 +2512,15 @@ autoref .code:n =
{\noexpand\klactivedoublequotationmark}
{\noexpand\klquotation_parse_arobas_sep:Nw
\noexpand\klquotation_expand:nnn #1
- @\klparse_novalue_tl
- @\klparse_novalue_tl
+ @
+ @
@\noexpand\kl_end}
}
\edef\klactivedoublequotationmark#1""{
\noexpand\klquotation_parse_arobas_sep:Nw
\noexpand\kldoublequotation_expand:nnn #1
- @\klparse_novalue_tl
- @\klparse_novalue_tl
+ @
+ @
@\noexpand\kl_end
}
\cs_new:Npx\klquotation_parse_arobas_sep:Nw #1#2@#3@#4@#5\kl_end
@@ -2244,10 +2528,14 @@ autoref .code:n =
\cs_set_eq:NN\tl_if_novalue:nTF\IfNoValueTF
-\cs_new:Nn\kldoublequotation_expand:nnn
- {\tl_if_novalue:nTF{#2}{\intro{#1}}{\intro[{#2}]{#1}}}
-\cs_new:Nn\klquotation_expand:nnn
- {\tl_if_novalue:nTF{#2}{\kl{#1}}{\kl[{#2}]{#1}}}
+\cs_new:Npn\kldoublequotation_expand:nnn
+ {\kl_activate_intro:\klquotation_expand:nnn}
+
+\cs_new:Nn\klquotation_expand:nnn{
+ \tl_if_empty:nTF{#2}
+ {\klTKS{#1}{#1}{#3}}
+ {\klTKS{#1}{#2}{#3}}
+}
\def\klactivatequotation
{\makequotationactive
@@ -2256,6 +2544,7 @@ autoref .code:n =
{\makequotationletter}
\kldeactivatequotation
+
\cs_new:Nn\kl_protect_environment_quotation:n
{\clist_map_inline:nn{#1}
{\scope_area_set:nn{#1}
@@ -2371,34 +2660,6 @@ autoref .code:n =
\NewKnowledgeParamTl*{index~style}\kl_index_style_tl
\NewKnowledgeParamTl*{index~parent~key}\kl_index_parent_tl
\NewKnowledgeParamTl*{index~key}\kl_index_key_tl
-\cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init:
-\tl_gset_eq:NN \knowledge_kl_namespace_tl\knowledge_defaultkl_namespace_tl
-\cs_gset_eq:NN\knowledge_kl_display_code:\knowledge_defaultkl_display_code:
-\cs_gset_eq:NN\knowledge_kl_update:N\knowledge_defaultkl_update:N
-\tl_gset:Nn\knowledge_kl_command_tl{\kl}
-\newcommand\robustdisplay[1]
- {\expandafter\tl_trim_spaces:n\expandafter{\detokenize{#1}}}
-\newcommand\robustdisplaybracket[1]
- {[\robustdisplay{#1}]}
-\cs_set_eq:NN\knowledge_error_display:n\use:n
-
-\bool_if:NTF\knowledge_xcolor_active_bool{
- \knowledgestyle{intro}{emphasize}
- \knowledgestyle{unknown}{wrap=\knowledge_error_display:n,color=red}
- \knowledgestyle{unknown~(cont)}{wrap=\knowledge_error_display:n,color=gray}
- \knowledgestyle{autoref~not~introduced}{wrap=\knowledge_error_display,color=orange}
- \knowledgestyle{autoref~not~introduced~(cont)}{wrap=\knowledge_error_display:n,color=gray}
- \knowledgestyle{autoref~reintroduced}{wrap=\knowledge_error_display:n,color=red}
- \knowledgestyle{autoref~reintroduced~(cont)}{wrap=\knowledge_error_display:n,color=red}
-}{
- \knowledgestyle{intro}{emphasize}
- \knowledgestyle{unknown}{wrap=\knowledge_error_display:n}
- \knowledgestyle{unknown~(cont)}{wrap=\knowledge_error_display:n}
- \knowledgestyle{autoref~not~introduced}{wrap=\knowledge_error_display:n}
- \knowledgestyle{autoref~not~introduced~(cont)}{wrap=\knowledge_error_display:n}
- \knowledgestyle{autoref~reintroduced}{wrap=\knowledge_error_display:n}
- \knowledgestyle{autoref~reintroduced~(cont)}{wrap=\knowledge_error_display:n}
-}
\ExplSyntaxOff\makeatletter
\newcommand\knowledgeFixHyperrefTwocolumn{
\RequirePackage{etoolbox}
@@ -2450,6 +2711,8 @@ autoref .code:n =
\DeclareExpandableDocumentCommand\IfKnowledgePaperModeTF{}
{\bool_if:NTF\knowledge_option_paper_bool}
+\DeclareExpandableDocumentCommand\IfKnowledgePaperModeF{}
+ {\IfKnowledgePaperModeTF{}}
\newif\ifKnowledgePaperMode
\IfKnowledgePaperModeTF
\KnowledgePaperModetrue
@@ -2461,67 +2724,78 @@ autoref .code:n =
\IfXcolorTF
\Xcolortrue
\Xcolorfalse
+\cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init:
+\tl_gset_eq:NN\knowledge_kl_namespace_tl\knowledge_defaultkl_namespace_tl
+\cs_gset_eq:NN\knowledge_kl_display_code:\knowledge_defaultkl_display_code:
+\cs_gset_eq:NN\knowledge_kl_update:N\knowledge_defaultkl_update:N
+\tl_gset:Nn\knowledge_kl_command_tl{\kl}
+\newcommand\robustdisplay[1]
+ {\expandafter\tl_trim_spaces:n\expandafter{\detokenize{#1}}}
+\newcommand\robustdisplaybracket[1]
+ {[\robustdisplay{#1}]}
+
+\IfKnowledgePaperModeTF{
+ \knowledgestyle{intro}{emphasize}
+ \knowledgestyle{unknown}{}
+ \knowledgestyle{intro unknown}{emphasize}
+}{}
+
+\IfKnowledgeCompositionModeTF{
+ \IfXcolorTF{
+ \knowledgestyle{intro}{emphasize}
+ \knowledgestyle{unknown}{color=brown}
+ \knowledgestyle{intro unknown}{emphasize,color=red}
+ }{
+ \knowledgestyle{intro}{emphasize}
+ \knowledgestyle{unknown}{underline}
+ \knowledgestyle{intro unknown}{emphasize,underline}}
+}{}
+
+\IfKnowledgeElectronicModeTF{
+ \IfXcolorTF{
+ \knowledgestyle{intro}{emphasize}
+ \knowledgestyle{unknown}{color=brown}
+ \knowledgestyle{intro unknown}{emphasize,color=red}
+ }{
+ \knowledgestyle{intro}{emphasize}
+ \knowledgestyle{unknown}{underline}
+ \knowledgestyle{intro unknown}{emphasize,underline}}
+}{}
+
\ExplSyntaxOff
-\newrobustcmd\KnowledgeConfigureNotion[1][blue]{
- \knowledgedirective{notion}
- {autoref,style=notion,intro style=intro notion}
+\newrobustcmd\KnowledgeConfigureNotion[2][blue]{
+ \knowledgedirective{#2}{autoref,style=#2,intro style=intro #2}
\ifKnowledgePaperMode
- \knowledgestyle{notion}{}
- \knowledgestyle{intro notion}{emphasize}
- \knowledgestyle{unknown}{}
- \knowledgestyle{unknown (cont)}{}
+ % paper mode
+ \knowledgestyle{#2}{}
+ \knowledgestyle{intro #2}{emphasize}
\fi
\ifKnowledgeCompositionMode
\ifXcolor
- \knowledgestyle{notion}{color={#1!70!black}}
- \knowledgestyle{intro notion}{emphasize,color={#1}}
- \knowledgestyle{unknown}{color=brown}
- \knowledgestyle{unknown (cont)}{color=brown}
+ % composition mode with colors
+ \knowledgestyle{#2}{color={#1!70!black}}
+ \knowledgestyle{intro #2}{emphasize,color={#1}}
\else
- \knowledgestyle{notion}{underline}
- \knowledgestyle{intro notion}{emphasize, underline}
- \knowledgestyle{unknown}{}
- \knowledgestyle{unknown (cont)}{}
+ % composition mode, no colors (use underline)
+ \knowledgestyle{#2}{underline}
+ \knowledgestyle{intro #2}{emphasize, underline}
\fi
\fi
\ifKnowledgeElectronicMode
\ifXcolor
- \definecolor{klDarkBlue}{rgb}{0,0,0.7}
- \knowledgestyle{notion}{color={#1!70!black}}
- \knowledgestyle{intro notion}{emphasize,color={#1}}
- \knowledgestyle{unknown}{}
- \knowledgestyle{unknown (cont)}{}
+ % electronic mode
+ \knowledgestyle{#2}{color={#1!70!black}}
+ \knowledgestyle{intro #2}{emphasize,color={#1}}
\else
- \knowledgestyle{notion}{underline}
- \knowledgestyle{intro notion}{emphasize, underline}
- \knowledgestyle{unknown}{}
- \knowledgestyle{unknown (cont)}{}
- \fi
+ % electronic mode, no colors (use underline)
+ \knowledgestyle{#2}{underline}
+ \knowledgestyle{intro #2}{emphasize, underline}
+ \fi
\fi
}
\ExplSyntaxOn
-\exp_args:NNV\ExplSyntaxOff\knowledgeconfigure\knowledge_configuration_pending_tl
-\ScopeActivate
-\ExplSyntaxOn
\knowledge_begin_module_if:N\knowledge_option_scope_bool
-\scope_area_set:nn{base}
-{
- occurrences = once,
- autoclose = false
-}
-\scope_area_set:nn{document}
-{
- autoclose = false,
- occurrences = once,
- parents = base
-}
-\scope_area_set:nn{body}
-{
- autoclose = true,
- occurrences = once,
- parents = document,
- }
\scope_area_set:nn
{part, section,subsection,subsubsection,
paragraph,subparagraph,subsubparagraph}
@@ -2573,36 +2847,28 @@ autoref .code:n =
\OverloadCommand\subsubparagraph{som}
{\scope_area_push:n{subsubparagraph}
\XparseArgs\SUPERsubsubparagraph{som}{#1}{#2}{#3}}
-\cs_new:Nn\scope_area_environment_new:nn
- {\scope_area_set:nn{#1}{
- parents = all,
- autoclose = false,
- occurrences = multiple,
- knowledge = attracts,
- #2
- }}
-
+\KnowledgeConfigureEnvironment?
+ {theorem,lemma,proposition,fact,conjecture,problem}
+ {category=theorem-like,label=accepts}
+\KnowledgeConfigureEnvironment?
+ {remark,proof}
+ {label=accepts,knowledge=accepts}
+\KnowledgeConfigureEnvironment?
+ {center,flushleft,flushright,minipage,quotation,quote,verbatim,verse}
+ {knowledge=accepts,label=none}
\OverloadCommand\newtheorem{m}
- {\scope_area_environment_new:nn
- {#1}
- {category=theorem-like}
+ {\KnowledgeConfigureEnvironment!{#1}{category=theorem-like,label=accepts}
\SUPERnewtheorem{#1}}
-
\OverloadCommand\newenvironment{m}
- {\scope_area_environment_new:nn
- {#1}
- {category=environment}
+ {\KnowledgeConfigureEnvironment!{#1}{label=accepts}
\SUPERnewenvironment{#1}}
\OverloadCommand\NewDocumentEnvironment{m}
- {\scope_area_environment_new:nn
- {#1}
- {category=environment}
+ {\KnowledgeConfigureEnvironment!{#1}{label=none}
\SUPERNewDocumentEnvironment{#1}}
\scope_area_set:nn
{itemize,enumerate,description}
{category=itemize-like}
-
\scope_area_set:nn{item}
{autoclose=true,
parents = itemize-like}
@@ -2621,7 +2887,12 @@ autoref .code:n =
forces = body
}
\knowledge_end_module:
-\ExplSyntaxOff
+
+%%%%%%%%%%
+\ExplSyntaxOn
+\exp_args:NNV\ExplSyntaxOff\knowledgeconfigure\knowledge_configuration_pending_tl
+\ScopeActivate
+
\endinput
%%
%% End of file `knowledge.sty'.