diff options
author | Karl Berry <karl@freefriends.org> | 2019-10-03 21:09:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-10-03 21:09:28 +0000 |
commit | 25aff3bb866d4722d9372cacffcb1bc0cb6afabc (patch) | |
tree | 69d44b6c3f5ec343aa1bfd3dc737b3b03d2fbf2b /Master/texmf-dist/tex/latex | |
parent | c855cf241a4beeea9508caf359f9090c6419cf8f (diff) |
knowledge (3oct19)
git-svn-id: svn://tug.org/texlive/trunk@52273 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/knowledge/knowledge.sty | 453 |
1 files changed, 304 insertions, 149 deletions
diff --git a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty index 2cb530221bd..35aaaea4b1d 100644 --- a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty +++ b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty @@ -23,12 +23,11 @@ %% LaTeX version 1999/12/01 or later. %% \usepackage{expl3} -\ProvidesExplPackage{knowledge}{2019/02/16}{1.16}{} +\ProvidesExplPackage{knowledge}{2019/10/03}{1.17}{} %%%%%%%%%% \RequirePackage{l3keys2e} \RequirePackage{etoolbox} \RequirePackage{xparse} -\RequirePackage{etoolbox} \bool_if_exist:NTF\knowledge_package_loaded_bool {\endinput} {\bool_new:N\knowledge_package_loaded_bool @@ -288,7 +287,6 @@ {\exp_not:n{\exp_after:wN\exp_args:Nc\exp_after:wN} ##1 \exp_not:c{#1_id_b:#2}} } - \cs_new:Nn\cell_specialize:nnn {\cs_new:cpx{#1_#2_id:#3} {\exp_not:c{#1_id:n#3}{#2}} @@ -790,6 +788,9 @@ \cs_new:Npn\klparse_if_novalue:NTF {\tl_if_eq:NNTF\klparse_novalue_tl} \cs_generate_variant:Nn\tl_to_str:n{V} +\tl_new:N\char_escape_tl +\tl_set:Nx\char_escape_tl + {\expandafter\tl_head:n\expandafter{\string\escape}} \cs_new:Nn\knowledge_info:n {\msg_info:nnn{knowledge}{knowledge~info}{#1}} \cs_new:Nn\knowledge_warning:n @@ -817,6 +818,8 @@ {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{ knowledge }{ knowledgedirective~redifinition } + { Directive~'#1'~already~exists~(\knowledgedirective~macro). } \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.} @@ -925,6 +928,9 @@ \bool_new:N\knowledge_configuration_diagnoseline_bool \bool_set_false:N\knowledge_configuration_diagnoseline_bool \KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnoseline_bool]{diagnose~line} +\bool_new:N\knowledge_configuration_barsuggestion_bool +\bool_gset_false:N\knowledge_configuration_barsuggestion_bool +\KnowledgeConfigureBooleanOption[\knowledge_configuration_barsuggestion_bool]{bar~suggestion} \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 @@ -937,7 +943,12 @@ \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 } @@ -1219,7 +1230,7 @@ \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 @@ -1317,6 +1328,7 @@ {\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} % @@ -1366,11 +1378,6 @@ {\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 @@ -1383,11 +1390,11 @@ {\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=}} +\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}} } \bool_new:N\scopept_map_break_bool \cs_new:Nn\scopept_map_break: @@ -1412,25 +1419,75 @@ {\scopept_map_instance_ancestors_i:nN{##1}#2 \bool_if:NTF\scopept_map_break_bool:{\seq_map_break:}{}} } -\NewDocumentCommand\scopeLabel{m} - { \kl_hide_begin: +\tl_const:Nn\knowledge_scopetag_tl{ScpT@g} +\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}}} +\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}} +} +\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}} +} +\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} + \KAuxWriteX*{\exp_not:n{\KAuxNewLinkScopetagInstance}{\exp_not:n{#1}}{\l_tmpb_tl}} +} +\bool_new:N\knowledge_configuration_label_autoscope_bool +\bool_gset_true:N\knowledge_configuration_label_autoscope_bool +\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}} + \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1} +} \let\label\scopeLabel \cs_new:Npn\knowledge_latex_label:n{ \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\label } +\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} +} \NewKAuxCommand\KAuxScopeNewInstance{mmm} {Package~scope:~Declares~a~new~instance~of~a~scope.} \DeclareKAuxPhaseCommand\KAuxScopeNewInstance{init} {\tl_new:cn{\scopept_tl.instance[#2].area_tl}{#1} \tl_new:cn{\scopept_tl.instance[#2].parent_tl}{#3}} -\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}}} \cs_new:Npn\scopept_label_instance_if_exist:nTF#1 @@ -1660,7 +1717,7 @@ \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} \NewDocumentCommand\NewKnowledgeParamBool{smm}{ \ktuple_new_bool_index:n{#2} \bool_new:N#3 @@ -1690,7 +1747,6 @@ }} } \NewDocumentCommand\NewKnowledgeParamTl{som}{ - %\tl_show:n{#2} \IfNoValueTF{#2} { \tl_set:Nn\l_tmpa_tl{#3} \tl_remove_all:Nn\l_tmpa_tl{~} @@ -1748,28 +1804,29 @@ \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: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{|}} +\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}} \cs_new:Nn\knowledge_show_visible_instances: {\tl_show:x {Visible~instances~<\seq_use:Nn\knowledge_visible_instances_seq{,}>}} -\cs_new:Nn\knowledge_import_instance:n - {\seq_if_in:NnTF\knowledge_visible_instances_seq{#1} - {}{\knowledge_push_visible_instance:n{#1}}} -\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: +\NewDocumentCommand\knowledgeimport{ >{\SplitList{,}}m }{ + \kl_hide_begin: + \ProcessList{#1}\knowledge_knowledgeimport:n + \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 + } \keys_define:nn { knowledge~directives } { namespace .code:n = { \tl_set:Nn\knowledge_knowledge_namespace_tl{#1} }, append .choice:, @@ -1784,16 +1841,16 @@ 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} }, + 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}}}, } \NewKAuxCommand\KAuxKnowledge{mmmm} {Package~knowledge:~Declares~a~knowledge.~ @@ -1827,9 +1884,9 @@ \cs_generate_variant:Nn\knowledge_new_now:nnnn{nnVn} \cs_generate_variant:Nn\knowledge_set_now:nnnn{nnVn} \NewDocumentCommand\knowledge{} - {\KAuxWriteLocation\__knowledge_knowledge} -\NewDocumentCommand\__knowledge_knowledge{t! t+ m >{\SplitList{|}}o m } -{ \kl_hide_begin: + {\KAuxWriteLocation\__knowledge_knowledge_init:w} +\NewDocumentCommand\__knowledge_knowledge_init:w{t! t+ m m}{ + \kl_hide_begin: \group_begin: % \IfBooleanTF{#1}{% @@ -1844,26 +1901,81 @@ \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}}} +} +\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} +} +\cs_new:Nn\__knowledge_knowledge_end:{ + \group_end: + \kl_hide_end: +} +\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: +} +\cs_new:Npn\knowledge_knowledge_newsyntax_firstline:n{} +\cs_new:Npn\knowledge_knowledge_newsyntax_nextlines:n{} +\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 +} +\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:} +} +\cs_new:Npn\knowledge_knowledge_newsyntax_exec_line:w#1\kl_end_line:{ + \knowledge_knowledge_newsyntax_exec_line:n{#1} +\kl_newknowledge_parse:w +} +\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 +\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}}} \NewDocumentCommand\knowledgestyle{ s m m } { \kl_hide_begin: \group_begin: @@ -1886,8 +1998,9 @@ \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 @@ -1964,17 +2077,24 @@ {\tl_set:Nn\knowledge_knowledge_directives_tl{#1}} {\tl_put_right:Nn\knowledge_knowledge_directives_tl{,#1}}} \cs_generate_variant:Nn\knowledge_delay_directive:n{x} -\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}}} +} \tl_new:N\knowledge_knowledgedefault_tl \NewDocumentCommand\knowledgedefault{sm}{ \kl_hide_begin: @@ -2033,14 +2153,12 @@ } \int_const:Nn\knowledge_kl_max_recursion_int{40} \int_new:N\knowledge_kl_recursion_int -\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:} } \cs_set:Npn\knowledge_kl_find_recursion_exceeded:TF{ \int_decr:N\knowledge_kl_recursion_int @@ -2057,13 +2175,31 @@ \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: } +\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} +} +\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 } \cs_new:Nn\knowledge_kl_find_withoutscope:{ \knowledge_kl_find_in_scope:VNTF @@ -2093,11 +2229,21 @@ {#5} } \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 + }{}} +} +\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:}{} +} \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{ @@ -2136,7 +2282,7 @@ \knowledge_kl_compute_code: } } -\cs_generate_variant:Nn\knowledge_kl_exec:nnn{nnV} +\cs_generate_variant:Nn\knowledge_kl_exec:nnn{nnV,VVV} \cs_new:Nn\knowledge_kl_use_styles:n {\clist_map_function:nN{#1}\knowledge_kl_use_style:n} \cs_generate_variant:Nn\knowledge_kl_use_styles:n {x} @@ -2179,13 +2325,25 @@ {} \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}} + } } \cs_new:Nn\knowledge_kl_error_unknown_firsttime: {\bool_if:cTF{\knowledge_variant_var:n{unknownwarning_bool}} @@ -2193,7 +2351,7 @@ \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{ @@ -2286,36 +2444,38 @@ \cs_new:Nn\knowledge_variant_var:n {knowledge_kl_\expandafter\cs_to_str:N\knowledge_kl_command_tl _#1} \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} @@ -2330,10 +2490,11 @@ \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 @@ -2345,10 +2506,14 @@ \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).}} } \keys_define:nn{ knowledge~configure~variant }{ namespace .code:n = @@ -2437,13 +2602,13 @@ \NewKnowledgeParamBool*{lowercase}\kl_lowercase_bool \NewKnowledgeParamBool*{uppercase}\kl_uppercase_bool \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} \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} @@ -2521,7 +2686,7 @@ \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: @@ -2644,7 +2809,7 @@ \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 @@ -2664,7 +2829,7 @@ }}{} } -\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} @@ -2994,14 +3159,14 @@ \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 @@ -3014,11 +3179,11 @@ } \knowledgenewvariant\reintro{ namespace=default, - 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} @@ -3032,27 +3197,21 @@ \ExplSyntaxOff \IfKnowledgePaperModeTF{ - \knowledgestyle{kl}{} \knowledgestyle{kl unknown}{} \knowledgestyle{kl unknown cont}{} - \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 unknown}{color=orange} \knowledgestyle{kl unknown cont}{color=brown} - \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 unknown}{underline} \knowledgestyle{kl unknown cont}{underline} - \knowledgestyle{intro}{emphasize,index style=introindexstyle} \knowledgestyle{intro unknown}{emphasize,underline} \knowledgestyle{intro unknown cont}{emphasize,underline} } @@ -3060,17 +3219,13 @@ \IfKnowledgeElectronicModeTF{ \IfXcolorTF{ - \knowledgestyle{kl}{color={blue!70!black}} \knowledgestyle{kl unknown}{} \knowledgestyle{kl unknown cont}{} - \knowledgestyle{intro}{emphasize,color=blue,index style=introindexstyle} \knowledgestyle{intro unknown}{emphasize} \knowledgestyle{intro unknown cont}{emphasize} }{ - \knowledgestyle{kl}{} \knowledgestyle{kl unknown}{} \knowledgestyle{kl unknown cont}{} - \knowledgestyle{intro}{emphasize,index style=introindexstyle} \knowledgestyle{intro unknown}{emphasize} \knowledgestyle{intro unknown cont}{emphasize} } |