diff options
author | Karl Berry <karl@freefriends.org> | 2019-12-03 22:05:20 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-12-03 22:05:20 +0000 |
commit | b35ea48fb406c5aaebc3b92c7ec228e03f75e58f (patch) | |
tree | cb46a95f3d488d3c04f85ed914148c543ea61da7 /Master/texmf-dist/source/latex/knowledge | |
parent | c7b7b71e49652c9ff0f4f3b2fa6a344041ddbeb1 (diff) |
knowledge (3dec19)
git-svn-id: svn://tug.org/texlive/trunk@53015 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/knowledge')
-rw-r--r-- | Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx | 272 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx | 53 |
2 files changed, 228 insertions, 97 deletions
diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx index 40ea1c6aa0e..d97ed2143af 100644 --- a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx +++ b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx @@ -23,7 +23,7 @@ % % \iffalse %<head>\usepackage{expl3} -%<head>\ProvidesExplPackage{knowledge}{2019/11/19}{1.19}{} +%<head>\ProvidesExplPackage{knowledge}{2019/12/03}{1.20}{} %<*driver> \def\knowledgecode{active} \input{knowledge.tex} @@ -52,6 +52,7 @@ % \changes{1.17}{2019/10/03}{improvements} % % \changes{1.18}{2019/10/03}{bug fix/improvement} % % \changes{1.19}{2019/11/19}{bug fix} % +% \changes{1.20}{2019/12/03}{bug fix} % % \GetFileInfo{knowledge.sty} % % \DoNotIndex{} % @@ -71,8 +72,8 @@ This directory contains the package name: knowledge license: LaTeX Project Public License version 1.2 or above - version: v1.19 - date: 2019/11/19 + version: v1.20 + date: 2019/12/03 author: Thomas Colcombet mail: thomas.colcombet@irif.fr web: https://www.irif.fr/~colcombe/knowledge_en.html @@ -171,6 +172,16 @@ Content of the file knowledge-sources.zip: {\expandafter\tl_head:n\expandafter{\string\escape}} % \end{macrocode} % +% \begin{macrocode} +\cs_new:Nn\debug_vars:nn{ + \iow_term:n{---~{#1}} + \tl_map_inline:nn{#2} + {\iow_term:x{\space\space\exp_not:N##1=\space\tl_if_exist:NTF##1 + {{\exp_not:V##1}} + {undefined}}} +} +% \end{macrocode} +% % \subsection{Messages of the package} % %\AP First, some generic messages that are produced using \csintro{\knowledge_info:n}, @@ -204,20 +215,20 @@ Content of the file knowledge-sources.zip: % \csintro{knowledge~unknown~in~scope}, \csintro{knowledge~unknown~label}, \csintro{package~required} and \csintro{knowledge~exists}. % \begin{macrocode} \msg_new:nnn{ knowledge }{ knowledge~recursion } - { The~knowledges~are~probably~cyclic,~starting~from~'#1'~(namespace~'#2'),~ + { The~knowledges~are~probably~cyclic,~starting~from\\<#1>~(namespace~'#2'),~ currently~at~'#3'.} % \end{macrocode} % \begin{macrocode} \msg_new:nnn{ knowledge }{ knowledge~unknown } - {The~knowledge~'#1'~could~not~be~found~in~scopes~<~#3~>~(namespace~'#2').} + {The~knowledge~'#1'~could~not~be~found~in~scopes\\<#3>~(namespace~'#2').} % \end{macrocode} % \begin{macrocode} \msg_new:nnn{ knowledge }{ knowledge~unknown~in~scope } - {The~knowledge~'#1'~could~not~be~found~in~scope~'#3'~(namespace~'#2').} + {The~knowledge~'#1'~could~not~be~found~in~scope\\<#3>~(namespace~'#2').} % \end{macrocode} % \begin{macrocode} \msg_new:nnn{ knowledge }{ knowledge~unknown~label } - {The~label~'#2'~could~not~be~found~while~searching~for~'#1'.~Possibly~rerun~latex.} + {The~label~'#2'~could~not~be~found~while~searching~for:\\<#1>\\Possibly~rerun~latex.} % \end{macrocode} % \begin{macrocode} \msg_new:nnn{ knowledge }{ package~required } @@ -254,12 +265,12 @@ Content of the file knowledge-sources.zip: % \end{macrocode} %\AP We define new the final messages, that are thrown at the end of the compilation as a recap that some problems occured. These are: \csintro{recap~unknown~knowledge}, \csintro{recap~autoref~introduced~twice} and \csintro{recap~autoref~not~introduced}. % \begin{macrocode} -\msg_new:nnn{knowledge}{recap~unknown~knowledge} - {Some~knowledge~are~not~defined.~See~the~'.diagnose'~file~for~more~information.} -\msg_new:nnn{knowledge}{recap~autoref~introduced~twice} - {Some~knowledge~is~introduced~twice.~See~the~'.diagnose'~file~for~more~information.} -\msg_new:nnn{knowledge}{recap~autoref~not~introduced} - {Some~knowledge~is~used~but~not~introduced.~See~the~'.diagnose'~file~for~more~information.} +\exp_args:Nnnx\msg_new:nnn{knowledge}{recap~unknown~knowledge} + {Some~knowledge~are~not~defined.~See~the~'\c_sys_jobname_str.diagnose'~file~for~more~information.} +\exp_args:Nnnx\msg_new:nnn{knowledge}{recap~autoref~introduced~twice} + {Some~knowledge~is~introduced~twice.~See~the~'\c_sys_jobname_str.diagnose'~file~for~more~information.} +\exp_args:Nnnx\msg_new:nnn{knowledge}{recap~autoref~not~introduced} + {Some~knowledge~is~used~but~not~introduced.~See~the~'\c_sys_jobname_str.diagnose'~file~for~more~information.} % \end{macrocode} % % @@ -431,11 +442,18 @@ Content of the file knowledge-sources.zip: \bool_set_false:N\knowledge_configuration_diagnoseline_bool \KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnoseline_bool]{diagnose~line} % \end{macrocode} +% Activates or deactivates the help in the "diagnose file". +% \begin{macrocode} +\bool_new:N\knowledge_configuration_diagnosehelp_bool +\bool_set_true:N\knowledge_configuration_diagnosehelp_bool +\KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnosehelp_bool]{diagnose~help} +% \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} +\bool_new:N\knowledge_configuration_diagnosebar_bool +\bool_gset_true:N\knowledge_configuration_diagnosebar_bool +\KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnosebar_bool]{bar~suggestion}%backward compatibility +\KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnosebar_bool]{diagnose~bar} % \end{macrocode} % % \begin{macrocode} @@ -1189,7 +1207,7 @@ Content of the file knowledge-sources.zip: {} } % \end{macrocode} -% The command \cs{\knowledge_scope_track_scope:n} +% \AP 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 @@ -1231,14 +1249,14 @@ Content of the file knowledge-sources.zip: % % \subsubsection{Scope tags} % -% A ""scopetag"" is a name that can be used to identify a family of "instances" that correspond to it. +% \AP 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) +% "instances" that are attached to it. It always contains (as soon as created) \textbf{explicit-scope:}\texttt{TAG}. % \end{description} % % In order to identify scopes, the command~\cs{\knowledgescope} (or \cs{\label} which is overloaded for this purpose). @@ -1280,7 +1298,7 @@ Content of the file knowledge-sources.zip: % \AP The command \csintro{\knowledgescope} associates an "instance" to one or more "scopetags": % \begin{macrocode} \NewDocumentCommand\knowledgescope{ >{\SplitList{,}}m }{ - \kl_hide_begin:\group_begin: + \kl_hide_begin:\group_begin: \ProcessList{#1}\knowledge_knowledgescope_one:n \group_end:\kl_hide_end: } @@ -1290,8 +1308,7 @@ Content of the file knowledge-sources.zip: \cs_new:Nn\knowledge_knowledgescope_one:n{ \knowledge_scopetag_declares:n{#1} \scope_get_labelizable_instance:N\l_tmpb_tl - \KAuxWriteX*{\exp_not:n{\KAuxNewLinkScopetagInstance}%{\exp_not:n{#1}}% old version - {#1}{\l_tmpb_tl}} + \KAuxWriteX*{\exp_not:N\KAuxNewLinkScopetagInstance{#1}{\l_tmpb_tl}} } % \end{macrocode} % @@ -1302,10 +1319,11 @@ Content of the file knowledge-sources.zip: \bool_new:N\knowledge_configuration_label_autoscope_bool \bool_gset_true:N\knowledge_configuration_label_autoscope_bool \KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{patch~label} +\KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{label~scope} % \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. +% \noindent\AP\csintro{\knowledgelabel} 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}{ +\NewDocumentCommand\knowledgelabel{m}{ \kl_hide_begin: \bool_if:NTF \knowledge_configuration_label_autoscope_bool @@ -1315,7 +1333,8 @@ Content of the file knowledge-sources.zip: \kl_hide_end: \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1} } -\let\label\scopeLabel +\let\scopeLabel\knowledgelabel%for backward compatibility +\let\label\knowledgelabel % \end{macrocode} % \AP In order to cicumvent this overloading, the normal \cs{\label} command % can be used using \csintro{\knowledge_latex_label:n}: @@ -1340,8 +1359,8 @@ Content of the file knowledge-sources.zip: \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} + \knowledge_scopetag_ensure:n{#1} + \seq_gput_right:cn{\knowledge_scopetag_tl[#1]_seq}{#2} } % \end{macrocode} % @@ -1425,7 +1444,7 @@ Content of the file knowledge-sources.zip: {\scope_area_pop:n{##1}} {}} \kutils_secure_latex_command:N\label - \let\label\scopeLabel + \let\label\knowledgelabel } % \end{macrocode} % @@ -1497,7 +1516,7 @@ Content of the file knowledge-sources.zip: {\scope_area_pop:n{knowledge~import~internal}} \NewDocumentEnvironment{knowledge~context}{m} {\ScopeActivate\scope_area_push:n{knowledge~context~internal} - \scopeLabel{#1}} + \knowledgelabel{#1}} {\scope_area_pop:n{knowledge~context~internal}} % \end{macrocode} % \subsection{Files} @@ -1506,8 +1525,9 @@ Content of the file knowledge-sources.zip: % \subsubsection{KAux file} % % Code to be executed before, at initialization and after the writing of the \kl{kaux file}. +% It tests before is the file was properly written during the last compilation using |\IfKAuxReadyTF|. % \begin{macrocode} -\KAuxBefore{\KAuxProcess{init}} +\KAuxBefore{\IfKAuxReadyTF{\KAuxProcess{init}}{}} \KAuxInit{} \KAuxAfter{\KnowledgeDiagnoseOutput} % \end{macrocode} @@ -1558,6 +1578,21 @@ Content of the file knowledge-sources.zip: \knowledge_diagnose:n{} \knowledge_diagnose:n{} % + \bool_if:NTF\knowledge_configuration_diagnosehelp_bool + { + \knowledge_diagnose:n{********} + \knowledge_diagnose:n{*~Help~*} + \knowledge_diagnose:n{********} + \knowledge_diagnose:n{} + \knowledge_diagnose:x{\use:c{@backslashchar}\cs_to_str:N\knowledgeconfigure{diagnose~bar=false}~deactivate~`|'-notation~in~diagnose~file.} + \knowledge_diagnose:x{\use:c{@backslashchar}\cs_to_str:N\knowledgeconfigure{diagnose~help=false}~deactivate~long~help~in~the~diagnose~file.} + \knowledge_diagnose:x{\use:c{@backslashchar}\cs_to_str:N\knowledgeconfigure{diagnose~line=true}~add~line~numbers~to~diagnose~file.} + \knowledge_diagnose:n{} + }{ + \knowledge_diagnose:x{\use:c{@backslashchar}\cs_to_str:N\knowledgeconfigure{diagnose~help=true}~to~activate~help~in~the~diagnose~file.} + \knowledge_diagnose:n{} + } + % \int_compare:nNnT\kl_digest_unknownknowledge_int>0{ \knowledge_diagnose:n{************************} \knowledge_diagnose:n{*~Undefined~knowledges~*} @@ -1565,6 +1600,8 @@ Content of the file knowledge-sources.zip: \knowledge_diagnose:n{} % \knowledge_diagnose_reset_line: + \bool_if:NT\knowledge_configuration_diagnosebar_bool + {\knowledge_diagnose:x{\use:c{@backslashchar}knowledge{ignore}}} \KAuxProcess{diagnose-unknown-suggest} % \knowledge_diagnose:n{} @@ -1952,17 +1989,13 @@ 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} }, - link~instance .code:n = - { \tl_set:Nn\knowledge_knowledge_instance_tl{#1} }, scope .code:n = - { \knowledge_scope_track_scope:n{#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_synonymlink_tl}, + {link={\exp_not:V\knowledge_knowledge_synonymlink_tl}, link~instance={\exp_not:V\knowledge_knowledge_synonyminstance_tl}}}, } % \end{macrocode} @@ -2049,7 +2082,7 @@ Content of the file knowledge-sources.zip: \bool_gset_false:N\knowledge_knowledge_is_synonym_bool % \tl_if_eq:nnTF{#4}{|} - {\__knowledge_knowledge_cont_newsyntax:nw{#3}|} + {\__knowledge_knowledge_cont_barnotation:nw{#3}|} {\tl_if_eq:nnTF{#4}{[} {\__knowledge_knowledge_cont_classical:nw{#3}[} {\__knowledge_knowledge_cont_classical:nw{#3}{#4}}} @@ -2071,6 +2104,7 @@ Content of the file knowledge-sources.zip: % \end{macrocode} % \begin{macrocode} \NewDocumentCommand\__knowledge_knowledge_cont_classical:nw{m >{\SplitList{|}}o m }{ + %\iow_term:n{\__knowledge_knowledge_cont_classical~{#1}{#3}} \knowledge_knowledge_setparseat:NNn\l_tmpa_tl\l_tmpb_tl{#1} % \use:x{ @@ -2081,6 +2115,9 @@ Content of the file knowledge-sources.zip: \tl_if_empty:NTF\l_tmpb_tl{}{,scope={\exp_not:V\l_tmpb_tl}}}} % \exp_args:NV\__knowledge_knowledge_recallsynonym:n\l_tmpa_tl + %\tl_show:N\l_tmpa_tl + %\tl_show:N\knowledge_knowledge_instance_tl + %\tl_show:N\knowledge_knowledge_immediate_synonym_directives_tl % \IfNoValueTF{#2}{}{ \cs_set:Nn\l_tmpa_cs:n @@ -2092,53 +2129,79 @@ Content of the file knowledge-sources.zip: \__knowledge_knowledge_end: } % \end{macrocode} +% \AP The code for the "`\vbar'-notation". +% \csintro{\knowledge_knowledge_barnotation_firstline:n} and \csintro{\knowledge_knowledge_barnotation_nextlines:n} +% contain the code to be executed when the first line is read, then the following ones. This is defined during parsing. +% \csintro{\knowledge_knowledge_barnotation_exec_line:n} changes from one value to the other during the parsing. % \begin{macrocode} -\cs_new:Npn\knowledge_knowledge_newsyntax_firstline:n{} +\cs_new:Npn\knowledge_knowledge_barnotation_firstline:n{} % \end{macrocode} % \begin{macrocode} -\cs_new:Npn\knowledge_knowledge_newsyntax_nextlines:n{} +\cs_new:Npn\knowledge_knowledge_barnotation_nextlines:n{} % \end{macrocode} +% \AP\csintro{\__knowledge_knowledge_cont_barnotation:nw} takes as first as argument the directives to be used for the +% defining the first "knowledge" (first argument in the "`\vbar'-notation"), and then it absorbs the content of the following line, +% from the first~`\vbar' to the line return. % \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 +\cs_new:Npn\__knowledge_knowledge_cont_barnotation:nw#1{ + \cs_set:Nn\knowledge_knowledge_barnotation_firstline:n{ + %\knowledge_knowledge_setparseat\g_tmpa_tl\g_tmpb_tl{#1} + %\iow_term:n{\knowledge{##1}{#1}~(first)} + \knowledge{##1}{#1} + \cs_set_eq:NN + \knowledge_knowledge_barnotation_exec_line:n + \knowledge_knowledge_barnotation_nextlines:n} + \cs_set:Nn\knowledge_knowledge_barnotation_nextlines:n + {%\iow_term:n{\exp_not:n{\knowledge{##1}}{synonym}} + \knowledge{##1}{synonym}} + \cs_set_eq:NN + \knowledge_knowledge_barnotation_exec_line:n + \knowledge_knowledge_barnotation_firstline:n + \kl_newknowledge_parse:w } % \end{macrocode} +% \AP Now the core of the parsing works by calling \csintro{\kl_newknowledge_parse:w}. +% It tests the existence of a starting `\vbar', and in this case absorb the line +% using \cs{\knowledge_knowledge_barnotation_exec_line:w} +% and calls \cs{\knowledge_knowledge_barnotation_exec_line:n} to +% execute it. This operation is repeated +% until there are no more starting `\vbar', and in this case \cs{\__knowledge_knowledge_end:} +% is used. % \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:} + \peek_charcode_remove_ignore_spaces:NTF| + {\kl_insert_klendline:w\knowledge_knowledge_barnotation_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 +\cs_new:Npn\knowledge_knowledge_barnotation_exec_line:w#1\kl_end_line:{ + \knowledge_knowledge_barnotation_exec_line:n{#1} + \kl_newknowledge_parse:w } % \end{macrocode} +% The catcode modifications for parsing a single line in "`\vbar'-notation": +% \AP The macro \csintro{\kl_insert_klendline:w} replaces the next occurrence of +% a line return by the control sequence \csintro{\kl_end_line:}. +% This temporarily changes the catcode. However, as soon as it is done, a normal command +% (meaning using the standard catcode regime) can then absorb the line. % \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} +% \AP How to break a line from the "`\vbar'-notation" in pieces. +% The \csintro{\knowledge_knowledge_setparseat:NNn}\ +% takes two tl-variables and the line content. +% The result is that the part before the first `@' is put inside the first variable, +% and what is after and before the next `@' (possibly empty) in the second one. % \begin{macrocode} \cs_new:Nn\knowledge_knowledge_setparseat:NNn - {\knowledge_knowledge_setparseat_:NNw#1#2#3@@\kl_end:} + {\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}}} + {\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} @@ -2229,9 +2292,9 @@ Content of the file knowledge-sources.zip: {} % \bool_if:NT\knowledge_knowledge_clear_bool - {\tl_put_left:Nn\knowledge_knowledge_directives_tl{clear,}} + {\tl_put_left:Nn\knowledge_knowledge_directives_tl{clear,}} \bool_if:NT\knowledge_knowledge_append_bool - {\tl_put_left:Nn\knowledge_knowledge_directives_tl{force,}} + {\tl_put_left:Nn\knowledge_knowledge_directives_tl{force,}} % \bool_if:nTF{\knowledge_knowledge_now_bool} {\use:x{ @@ -2348,8 +2411,9 @@ Content of the file knowledge-sources.zip: } % \end{macrocode} % -% \AP The following macro, \csintro{\knowledge_klTKS:nnn} is an internal version of \cs{\kl}-like commands. it takes explicitely the text to be displayed, -% followed by the \kl{knowledge name} to be used, and a \kl{label} pointing to the \kl[instance]{instance of scope} +% \AP The following macro, \csintro{\knowledge_klTKS:nnn} is an internal version of \cs{\kl}-like commands. +% It takes explicitly (1) the text to be displayed, +% (2) the \kl{knowledge name} to be used for the search, and (3) a \kl{label} pointing to the \kl[instance]{instance of scope} % in which the \kl{knowledge name} has to be searched for. This \kl{label} can be empty, and in this case, this means that % the stack of instances that are visible in the context of the call of the command should be inspected for searching for % the knowledge. @@ -2372,14 +2436,18 @@ Content of the file knowledge-sources.zip: % \end{macrocode} % \begin{macrocode} \cs_new:Nn\knowledge_klTKS:nnn{ + %\iow_term:n{\knowledge_klTKS:nnn{#1}{#2}{#3}} \group_begin: % \tl_set:Nx\knowledge_kl_linkscope_tl{\tl_to_str:n{#3}} - \tl_set:Nn\knowledge_kl_instance_tl{} + \tl_set:Nn\knowledge_kl_linkinstance_tl{} \tl_set:Nn\knowledge_kl_text_tl{#1} \tl_set:Nx\knowledge_kl_base_key_tl{\tl_to_str:n{#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 + %\debug_vars:nn{klTKS:nnn} + % {\knowledge_kl_linkscope_tl\knowledge_kl_linkinstance_tl + % \knowledge_kl_text_tl\knowledge_kl_base_key_tl} % \tl_if_exist:cTF {knowledge_kl_\tl_to_str:V\knowledge_kl_modifiers_tl _init_tl} @@ -2420,7 +2488,9 @@ Content of the file knowledge-sources.zip: \knowledge_kl_find_recursion_exceeded:TF \knowledge_kl_error_recursion: {\tl_if_empty:NTF\knowledge_kl_linkscope_tl - \knowledge_kl_find_withoutscope: + {\tl_if_empty:NTF\knowledge_kl_linkinstance_tl + {\knowledge_kl_find_withoutscope:} + {\knowledge_kl_find_withinstance:}} \knowledge_kl_find_withscopetag:} } % \end{macrocode} @@ -2435,23 +2505,25 @@ Content of the file knowledge-sources.zip: \cs_new:Nn\knowledge_kl_find_withinstance:{ \knowledge_knowledge_if_exist:VVVTF \knowledge_kl_namespace_tl - \knowledge_kl_instance_tl + \knowledge_kl_linkinstance_tl \knowledge_kl_key_tl {\knowledge_kl_exec:nnV \knowledge_kl_namespace_tl - \knowledge_kl_instance_tl + \knowledge_kl_linkinstance_tl \knowledge_kl_key_tl} { \knowledge_kl_error_unknown_in_scope_firsttime: } } % \end{macrocode} -% \csintro{\knowledge_kl_find_withscopetag:} searches for the knowledge, with a given scopetag +% \AP \csintro{\knowledge_kl_find_withscopetag:} searches for the knowledge, with a given "scopetag". % \begin{macrocode} \cs_new:Nn\knowledge_kl_find_withscopetag:{ + %\debug_vars:nn{\knowledge_kl_find_withscopetag:}{\knowledge_kl_linkscope_tl} \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 + % tests whether the search was successful \tl_if_empty:NTF\l_tmpa_tl {\knowledge_kl_error_unknown_in_scope_firsttime:} {\knowledge_kl_exec:VVV @@ -2460,10 +2532,14 @@ Content of the file knowledge-sources.zip: \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. +% \AP \csintro{\knowledge_kl_find_scopetag:Nn} takes a tl variable 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 transferred to the token list. \csintro{\knowledge_kl_find_scopetag_tmpa:n} +% uses as variable \cs{\l_tmpa_tl} % \begin{macrocode} +\cs_new:Npn\knowledge_kl_find_scopetag_tmpa:n{ + \knowledge_kl_find_scopetag:Nn\l_tmpa_tl +} \cs_new:Nn\knowledge_kl_find_scopetag:Nn{ \tl_if_empty:NTF#1 {\knowledge_knowledge_if_exist:VnVTF @@ -2474,23 +2550,25 @@ Content of the file knowledge-sources.zip: {}} {} } -\cs_new:Npn\knowledge_kl_find_scopetag_tmpa:n{ - \knowledge_kl_find_scopetag:Nn\l_tmpa_tl -} % \end{macrocode} % \begin{macrocode} \cs_new:Nn\knowledge_kl_find_withoutscope:{ + %\debug_vars:nn{\knowledge_kl_find_withoutscope:} + % {\knowledge_kl_key_tl\knowledge_kl_linkinstance_tl} + %\exp_args:NVVV\knowledge_knowledge_if_exist:nnnTF + % \knowledge_kl_namespace_tl\knowledge_kl_linkinstance_tl\knowledge_kl_key_tl + % {\tl_show:n{found}}{\tl_show:n{not~found}} \knowledge_kl_find_in_scope:VNTF \knowledge_kl_key_tl - \knowledge_kl_instance_tl - {\knowledge_kl_exec:nnV + \knowledge_kl_linkinstance_tl + {\knowledge_kl_exec:VVV \knowledge_kl_namespace_tl - \knowledge_kl_instance_tl + \knowledge_kl_linkinstance_tl \knowledge_kl_key_tl} {\knowledge_kl_error_unknown_firsttime:} } % \end{macrocode} -% \cs{\knowledge_kl_find_in_scope:nNTF} introduces the namespace as +% \AP \csintro{\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{ @@ -2498,12 +2576,13 @@ Content of the file knowledge-sources.zip: \knowledge_kl_namespace_tl } % \end{macrocode} -% We now code the macro \cs{\knowledge_kl_find_in_scope:nnNTF}, that +% \AP We now code the macro \csintro{\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: + %\tl_show:n{\knowledge_kl_find_in_scope:~#1/#2/#3} \tl_set:Nn\l_tmpa_tl{#1} \tl_set:Nn\l_tmpb_tl{#2} \bool_gset_false:N\g_tmpa_bool @@ -2518,17 +2597,17 @@ Content of the file knowledge-sources.zip: % \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. +% "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 - }{}} + \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} @@ -2557,13 +2636,14 @@ Content of the file knowledge-sources.zip: \cs_new:Nn\knowledge_kl_exec:nnn{ \tl_set:Nx\knowledge_kl_resourcearguments_tl {{#1}{#2}{\exp_not:n{#3}}} + %\debug_vars:nn{\knowledge_kl_exec:nnn}{\knowledge_kl_resourcearguments_tl} \exp_args:NNc\tl_set:Nn\knowledge_kl_resourcetoken_tl {\knowledge_id:nnn{#1}{#2}{#3}} \expandafter\ktuple_countuse_gincr:N\knowledge_kl_resourcetoken_tl % \tl_clear:N\knowledge_kl_link_tl \tl_clear:N\knowledge_kl_linkscope_tl - \tl_clear:N\knowledge_kl_instance_tl + \tl_clear:N\knowledge_kl_linkinstance_tl \tl_map_function:NN \knowledge_kl_styledirectives_tl \tl_clear:N @@ -2662,7 +2742,7 @@ Content of the file knowledge-sources.zip: {\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{ + \bool_if:NTF\knowledge_configuration_diagnosebar_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}{} @@ -3045,7 +3125,7 @@ Content of the file knowledge-sources.zip: % \begin{macrocode} \NewKnowledgeParamTl*{link} \NewKnowledgeParamTl*[\knowledge_kl_linkscope_tl]{link~scope} -\NewKnowledgeParamTl*[\knowledge_kl_instance_tl]{link~instance} +\NewKnowledgeParamTl*[\knowledge_kl_linkinstance_tl]{link~instance} \NewKnowledgeParamTl*[\knowledge_kl_forcedtext_tl]{text} \NewKnowledgeParamTl*{wrap} % \end{macrocode} @@ -3848,7 +3928,13 @@ Content of the file knowledge-sources.zip: \expandafter{\tl_to_str:n{#1}}} \newcommand\robustdisplaybracket[1] {[\robustdisplay{#1}]} - +% \end{macrocode} +% The ignore directive does nothing... +% \begin{macrocode} +\knowledgedirective{ignore}{} +% \end{macrocode} +% +% \begin{macrocode} \ExplSyntaxOff % in paper mode, nothing is displayed \IfKnowledgePaperModeTF{ diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx index dc0f0deed7c..477d57c188b 100644 --- a/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx +++ b/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx @@ -323,11 +323,46 @@ \KAuxWrite*{}} \NewDocumentCommand\KAuxClose{} - {\iow_close:N\knowledge_kaux_iow + {\KAuxWrite*{\KAuxEOF {}} + \iow_close:N\knowledge_kaux_iow \bool_gset_true:N\kaux_can_be_used_bool \kaux_posttreatment_tl } % \end{macrocode} +% Testing if the KAux file is complete. +% |\kaux_if_exist_containline:nnTF| tests if a line of a file is equal to the argument. +% This has to be used with care: the searched line is transformed into a str, thus introducing +% potential extra spaces after the control sequences. +% Also, when lines are read from the files, the trailing spaces are lost. +% Anyway, |IfKAuxReadyTF| tests for the presence of |\KAuxEOF {}| in a proper way. +% \begin{macrocode} +\cs_new:Npn\kaux_if_exist_containline:nnTF#1#2{ + \file_if_exist:nTF{#1}{ + \ior_open:Nn\klg_tmpa_ior{#1} + \bool_gset_false:N\g_tmpa_bool + \bool_gset_false:N\g_tmpb_bool + \str_gset:Nn\g_tmpb_str{#2} + \bool_do_until:Nn\g_tmpa_bool{ + \ior_if_eof:NTF\klg_tmpa_ior + {\bool_set_true:N\g_tmpa_bool} + { + \ior_str_get:NN\klg_tmpa_ior\g_tmpa_str + %\iow_term:x{(\exp_not:V\g_tmpa_str)=?(\exp_not:V\g_tmpb_str)} + \str_if_eq:NNTF\g_tmpa_str\g_tmpb_str + {\bool_gset_true:N\g_tmpa_bool + \bool_gset_true:N\g_tmpb_bool} + {} + }} + \ior_close:N\klg_tmpa_ior + %\bool_show:N\g_tmpb_bool + \bool_if:NTF\g_tmpb_bool + } + {\use_ii:nn} +} + +\NewDocumentCommand\IfKAuxReadyTF{} + {\exp_args:Nx\kaux_if_exist_containline:nnTF{\c_sys_jobname_str.kaux}{\KAuxEOF {}}} +% \end{macrocode} % % % @@ -386,6 +421,14 @@ \tl_gset:cn{kaux_\cs_to_str:N#1-args_tl}{#2} \tl_gput_right:Nn\kaux_command_list_tl{#1} } +% \end{macrocode} +% As an example, |\KAuxEOF| describes is used at the end of the Kaux file. +% \begin{macrocode} +\NewKAuxCommand\KAuxEOF{m} + {Does~nothing,~useless~empty~argument + ,~and~is~searched~for~knowing~if~the~kaux~file~was~written~till~the~end.} +% \end{macrocode} +% \begin{macrocode} \NewDocumentCommand\KAuxCommand{mmm} { \cs_if_exist:NTF #1 {} @@ -524,7 +567,7 @@ % \subsection{References} % % This is an old part of the code which is difficult to read. -% It should probably be cleaned. +% It should be cleaned. But this is a lot of work. % % When using \cs{\cell_new_type:nnn}, a new name space is created, % in which can be stored information. The first parameter is the name space. The second @@ -1010,7 +1053,8 @@ \ior_close:N\klg_tmpa_ior \iow_close:N\klg_tmpa_iow \group_end:}} - +% \end{macrocode} +% \begin{macrocode} \cs_new_protected_with_variants:Nnn\kl_compare_files:Nnn{NnV,NVn,NVV} {\group_begin: \bool_set_false:N\l_tmpa_bool% set when finished @@ -1052,7 +1096,8 @@ {\group_end:\bool_set_true:N#1} {\group_end:\bool_set_false:N#1} } - +% \end{macrocode} +% \begin{macrocode} \cs_new_protected:Nn\kl_tl_to_file:nn {\iow_open:Nn\klg_tmpa_iow{#1} \iow_now:Nn\klg_tmpa_iow{#2} |