From b35ea48fb406c5aaebc3b92c7ec228e03f75e58f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 3 Dec 2019 22:05:20 +0000 Subject: knowledge (3dec19) git-svn-id: svn://tug.org/texlive/trunk@53015 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/knowledge/README.md | 4 +- .../texmf-dist/doc/latex/knowledge/knowledge.pdf | Bin 697731 -> 702619 bytes .../texmf-dist/doc/latex/knowledge/knowledge.tex | 79 +++--- .../source/latex/knowledge/knowledge-code.dtx | 272 ++++++++++++++------- .../source/latex/knowledge/knowledge-utils.dtx | 53 +++- .../texmf-dist/tex/latex/knowledge/knowledge.sty | 234 ++++++++++++------ 6 files changed, 432 insertions(+), 210 deletions(-) diff --git a/Master/texmf-dist/doc/latex/knowledge/README.md b/Master/texmf-dist/doc/latex/knowledge/README.md index a5bc16beaaa..81a9ddf7f81 100644 --- a/Master/texmf-dist/doc/latex/knowledge/README.md +++ b/Master/texmf-dist/doc/latex/knowledge/README.md @@ -3,8 +3,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 diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf b/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf index 7412086a72a..b2e551fbb91 100644 Binary files a/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf and b/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf differ diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge.tex b/Master/texmf-dist/doc/latex/knowledge/knowledge.tex index d567aa36045..d65b26a4591 100644 --- a/Master/texmf-dist/doc/latex/knowledge/knowledge.tex +++ b/Master/texmf-dist/doc/latex/knowledge/knowledge.tex @@ -188,7 +188,10 @@ \knowledgeconfigure{quotation=false} -\knowledge{LaTeX}[latex|LATEX|Latex]{text=\LaTeX, color=black} +\knowledge{LaTeX}[latex|LATEX|Latex]{text=\LaTeX} +\knowledge{tex}[TeX|TEX]{text=\TeX} +\knowledge{pdflatex}{typewriter} + \knowledge"{text=\quotesymbol} \knowledge{""}{text=\quotesymbol\quotesymbol} \knowledgeconfigure{quotation=true} @@ -220,7 +223,6 @@ \knowledge{{@}}{kcommand,text=\arobas} -\knowledge{tex}{text=\TeX} \knowledgedirective{people}{emphasize,color=DarkGray} \knowledge{stackexchange}{people} @@ -317,8 +319,7 @@ \knowledge{index key=}{directive} \knowledge{index parent key=}{directive} \knowledge{index style=}{directive} -\knowledge{bar suggestion=}{directive} -\knowledge{patch label}[patch label=]{option} +\knowledge{label scope}[label scope=]{option} \knowledge{color=}{directive} \knowledge{cyclic color}{directive} \knowledge{colorbox=}{directive} @@ -357,8 +358,9 @@ \knowledge{unprotect link co}{option,text=unprotect link} \knowledge{hyperlinks=}{option} \knowledge{fix hyperref twocolumn}{option} +\knowledge{diagnose help=}[diagnose help]{option} \knowledge{diagnose line=}[diagnose line]{option} -\knowledge{bar suggestion=}[bar suggestion]{option} +\knowledge{diagnose bar=}[diagnose bar]{option} \knowledge{active}{option} @@ -469,10 +471,6 @@ | scope | scopes | Scopes -\knowledge{doc notion} - | explicit scope - | Explicit scopes - | explicit scopes \knowledge{doc notion} | scopetag | scopetags @@ -521,9 +519,6 @@ \knowledge {scope.sty}{link=scope option} -\knowledge{latex}{text=\LaTeX} -\knowledge{tex}{} -\knowledge{pdflatex}{} \knowledgedefault{} @@ -741,9 +736,12 @@ This involves testing the counter |beamer@coveringdepth| which if higher than o "Explicit scopes" are introduced. Updating of the documentation. "up" directive in math mode now silently does nothing, and \cs{\knowledgedirective} now forbids redefinitions by default (thanks to Léo Stefanesco). \item[2019-07-02] Removing the `\texttt{kl}' and `\texttt{intro}' styles that prevented a proper configuration of "intro notion@@style" (thanks to Léo Stefanesco). \item[2019-10-03] Update of the documentation, and V1.17. -\item[2019-10-27] Bug correction and added the `\kl{patch label}' configuration directive (thanks to \href{https://becca.ooo/}{Rebecca Turner}). V1.18. +\item[2019-10-27] Bug correction and added the `\textbf{patch label}' configuration directive (thanks to \href{https://becca.ooo/}{Rebecca Turner}). V1.18. \item[2019-11-19] Now the labels are evaluated before being written to the "kaux file" in a \cs\KAuxNewLinkScopetagInstance\ command (bug fix). V1.19. - \end{compactdesc} +\item[2019-11-29] Help added in the "diagnose file". \textbf{bar suggestion} (still working) renamed to "diagnose bar", and activated by default. \textbf{patch label} is renamed into "label scope". +\item[2019-12-02] The "kaux file" is now checked for completeness befre being used. This should avoid errors when the previous compilation failed. +\item[2019-12-03] Corrected bug in the scope access. V1.20 +\end{compactdesc} \normalsize %\restoregeometry @@ -1229,8 +1227,11 @@ be used in the optional parameter of \cs{\usepackage} when loading the "knowledg ""Configuration directives"" consists of a comma separated list of elements that can take the following values: \begin{description} -\itemAP["diagnose line="] can be set to true or false. It activates or deactivates the line numbering in the "diagnose file". False is the default. +\itemAP["diagnose bar="] (de)activates the "`\vbar'-notation" in the "diagnose file". True by default. +\itemAP["diagnose help="] can be set to true or false. It activates or deactivates the help in the "diagnose file". True by default. +\itemAP["diagnose line="] can be set to true or false. It activates or deactivates the line numbering in the "diagnose file". False by default. \itemAP[\kl{fix hyperref twocolumn}] triggers a hack that solves a known problem that may occur when "hyperref@@package" is used in two-columns mode. +\itemAP[\kl{label scope}] enables or disables the redefined \cs{\label} command, which helps automatically define scopes (default is~\textmd{true}). \itemAP["notion@@option"] configures the "notion" "directive" which is a refined version of "autoref". \itemAP["protect quotation="] is followed by a comma separated list of environments in which the "quotation notation" will be automatically deactivated (surrounded by braces if more than one item in the list). \itemAP[\intro{protect link co} and \intro{unprotect link co}] starts and ends respectively a zone in which the "knowledge@@package" package do not create hyperlinks. These can be nested. @@ -1879,13 +1880,27 @@ The following code (that requires the "scope option" for being functional) shoul It is often the case in a text, that one has to locally break the nesting structure of a document, and refer to a object local in an environment. For instance, a comment may refer to a variables/concept that has been locally used in the proof. The "knowledge@@package" provides suitable mechanisms for complex referencing of scopes. Let us explain this through an example: \begin{code} -\cs\begin{definition}\cs\label{} -\indent~~\cs\knowledge{} -\cs\end{definition} +\textcolor{gray}{\% We declare first in the preamble the environments that use knowledge.}\\ +\cs\knowledgeconfigureenvironment\{definition\}\{knowledge=attracts\}\par\indent +{[...]}\\ +\indent +\cs\begin\{definition\}\cs\label\{somewhere\}\\ +\indent~~\cs\knowledge\{something\}\{notion\}\\ +\indent~~Here, \cs\intro\{something\} is a notion internal to the definition. +\cs\end\{definition\} \end{code} +Note here that what is important is the location of the \cs\knowledge\ command, irrespective of the location ofthe \cs\intro\ command. +\AP The \cs\label\ command is used to name the "scope". In fact, the real command is +\begin{center} + \smallcode{\csintro\knowledgescope\{scope name\}} +\end{center}\noindent +which associates a scope name to the surrounding environment (providing it has been declared possible to do it using +\cs\knowledgeconfigureenvironment). +\AP +The standard \LaTeX\ command \cs\label\ is overloaded and performs implicitly a call to \cs\knowledgescope\ (this behavior can be deactivated/reactivated using the ""label scope=""\texttt{\{true,false\}} directive). The result is that the same string of characters can be used in order to name the scope, and at the same time is used as a standard \LaTeX\ label. -Something important is missing so far: one rapidly wants to access to \kl{knowledges} that do not exist in the current \kl{scope}. For instance, a notion is used in a section of a document, and one would like to refer to it in the introduction. Another case is that of a notion or a mathematic variable that is introduced in the statement of a theorem, and should be accessible inside the proof. There are essentially two ways to access such distance \kl{knowledges}: either use the \smallcode{\cs\kl(label)\{text\}} command (or the equivalent \smallcode{\kl{"...@...@..."}} notation), or use the \cs{\knowledgeimport} command. We describe the second possibility now. The syntax is: +\AP Something important is missing so far: one rapidly wants to access to \kl{knowledges} that do not exist in the current \kl{scope}. For instance, a notion is used in a section of a document, and one would like to refer to it in the introduction. Another case is that of a notion or a mathematic variable that is introduced in the statement of a theorem, and should be accessible inside the proof. There are essentially two ways to access such distant \kl{knowledges}: either use the \smallcode{\cs\kl(label)\{text\}} command (or the equivalent \smallcode{\kl{"...@...@..."}} notation), or use the \cs{\knowledgeimport} command. We describe the second possibility now. The syntax is: \begin{center} \smallcode{\csintro\knowledgeimport\{label\}} \end{center} @@ -1967,18 +1982,19 @@ The detail of the problems are then gathered in the \kl{diagnose file}. \label{subsection:diagnose file} The \intro{diagnose file} is a file that is created when the "knowledge@@package" package is used -(note that another file, ""jobname.kaux"" is also created by the "knowledge@@package" package, for internal use). It enormously eases the use of the package, and it is a good habit to sometimes check it. It gathers a certain number of informations, that can be warning, code to be used, or simply information. This file has the name of the tex document with the extension \kl{.diagnose}. Its content is divided into clearly identified parts. Depending on the used options, some of these parts may appear or disappear. +(note that another file, ""jobname.kaux"" is also created by the "knowledge@@package" package, for internal use). It enormously eases the use of the package, and it is important to look into it when finalizing a document. It gathers a certain number of informations, that can be warning, code to be used, or simply information. This file has the name of the tex document with the extension \kl{.diagnose}. Its content is divided into clearly identified parts. Depending on the used options, some of these parts may appear or disappear. \begin{description} \itemAP[\intro{Undefined knowledges}] in this section are listed all the knowledges that have been unsuccessfully searched for. These are given in lines either of the form - \begin{quote} - \texttt{\cs{\knowledge}\{undefined knowledge\}\{\textit{suggested directives}\}} - \end{quote} - or of the form \begin{quote} \texttt{\cs{\knowledge}\{\textit{suggested directives}\}\\ - \indent~~~\klbn|~~undefined knowledge}\textit{[\klbn@scope]} + \indent~~~\klbn|~~undefined knowledge}\textit{[\klbn@scope]}\\ + \indent~~~~~~~~~~~~~~\vdots \end{quote} - \AP Switching from one mode to another is obtained using the "configuration directive" ""bar suggestion=""\{true,false\} (default is true). + or of the form + \begin{quote} + \texttt{\cs{\knowledge}\{undefined knowledge\}\{\textit{suggested directives}\}} + \end{quote} + \AP Switching from one mode to another is obtained using the "configuration directive" "diagnose bar="\{true,false\} (default is true). The intent is that copying the content of this section to the document itself will solve all problems of \kl{undefined knowledges}. It is an efficient way, when one has written a document without caring so much about knowledges to copy the content of this section, and then modify it/reorganize it, in order to suit ones purposes. By default, no suggestion is offered, or "notion" is suggested if the "notion@@option" directive has been used. Suggestion can be automatically configured using the "suggestion=@@variant" "directive@@variant" of the macros \cs{\knowledgenewvariant} and \cs{\knowledgesetvariant}. @@ -2001,9 +2017,8 @@ This can be activated using the "diagnose line" boolean option: \end{center} \AP By default, the "diagnose file" gives suggestions to be used with the normal \cs\knowledge\ syntax. A "`\vbar'-notation" suggestion can be activated using: -This can be activated using the "diagnose line" boolean option: \begin{center} -\smallcode{\cs\knowledgeconfigure\{""bar suggestion=""true\}} +\smallcode{\cs\knowledgeconfigure\{""diagnose bar=""true\}} \end{center} \iffalse @@ -2369,9 +2384,9 @@ I do not know to which extend it is compatible with various classes... \subsubsection{The "notion@@option" directive} -The configuration option~\intro(option){notion} is activated using: +\AP The configuration option~\intro(option){notion} is activated using: \begin{center} -\smallcode{\cs\knowledgeconfigure\{\intro(option){notion}\}} +\smallcode{\cs\knowledgeconfigure\{\kl(option){notion}\}} \end{center}\noindent \AP It automatically configures a \kl[\knowledge directives]{directive} \intro{notion} which is an \kl{autoref} displayed properly: @@ -2710,7 +2725,7 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr \label{subsection:configuration directive list} \begin{compactdesc} -\item["bar suggestion="\textmd{\{true,false\}}] activates the \kl{`\vbar'-notation} in the "diagnose file" (default is false) +\item["diagnose bar="\textmd{\{true,false\}}] activates the \kl{`\vbar'-notation} in the "diagnose file" (default is false) \item["composition"] switches to "composition mode", \item["cyclic colors=@@option"] fixes the cyclic list of colors used by the "directive" "cyclic color". \item["diagnose line="\textmd{\{true,false\}}] activates or deactivates the line numbering in the "diagnose file". @@ -2720,7 +2735,7 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr \item[\kl{hyperlinks=}\textmd{\{true,false\}}] activates or deactivates the hyperlinks. \item[{{\kl(option){notion}}}] activates the "notion" directive \item["paper"] switches to "paper mode", -\itemAP[\kl{patch label}] enables or disables the redefined \cs{\label} command, which helps automatically define scopes (default is~\textmd{true}). +\itemAP[\kl{label scope=}\textmd{\{true,false\}}] enables or disables the redefined \cs{\label} command, which helps automatically define scopes (default is~\textmd{true}). \item[\kl{protect link co} and \kl{unprotect link co}] starts and ends respectively a zone in which the "knowledge@@package" package does not create hyperlinks. \item[\kl{protect quotation=}\textmd{\{environment list\}}] declares a list of environment in which the "quotation notation" should be deactivated \item[{{\kl(option)[quotation]{quotation=}\textmd{\{true,false\}}}}] activates or deactivates the "quotation notation". 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 %\usepackage{expl3} -%\ProvidesExplPackage{knowledge}{2019/11/19}{1.19}{} +%\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} diff --git a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty index 93019b0dbd0..fab365a87c9 100644 --- a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty +++ b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty @@ -23,7 +23,7 @@ %% LaTeX version 1999/12/01 or later. %% \usepackage{expl3} -\ProvidesExplPackage{knowledge}{2019/11/19}{1.19}{} +\ProvidesExplPackage{knowledge}{2019/12/03}{1.20}{} %%%%%%%%%% \RequirePackage{l3keys2e} \RequirePackage{etoolbox} @@ -159,10 +159,37 @@ \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 } +\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 {}}} \NewDocumentCommand\KAuxBefore{m} {\tl_gput_right:Nn\kaux_pretreatment_tl{#1}} \NewDocumentCommand\KAuxAfter{m} @@ -184,6 +211,9 @@ \tl_gset:cn{kaux_\cs_to_str:N#1-args_tl}{#2} \tl_gput_right:Nn\kaux_command_list_tl{#1} } +\NewKAuxCommand\KAuxEOF{m} + {Does~nothing,~useless~empty~argument + ,~and~is~searched~for~knowing~if~the~kaux~file~was~written~till~the~end.} \NewDocumentCommand\KAuxCommand{mmm} { \cs_if_exist:NTF #1 {} @@ -624,7 +654,6 @@ \ior_close:N\klg_tmpa_ior \iow_close:N\klg_tmpa_iow \group_end:}} - \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 @@ -666,7 +695,6 @@ {\group_end:\bool_set_true:N#1} {\group_end:\bool_set_false:N#1} } - \cs_new_protected:Nn\kl_tl_to_file:nn {\iow_open:Nn\klg_tmpa_iow{#1} \iow_now:Nn\klg_tmpa_iow{#2} @@ -791,6 +819,13 @@ \tl_new:N\char_escape_tl \tl_set:Nx\char_escape_tl {\expandafter\tl_head:n\expandafter{\string\escape}} +\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}}} +} \cs_new:Nn\knowledge_info:n {\msg_info:nnn{knowledge}{knowledge~info}{#1}} \cs_new:Nn\knowledge_warning:n @@ -806,14 +841,14 @@ \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'),~ + { 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').} + {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').} + {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.} + {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 } @@ -835,12 +870,12 @@ \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.} -\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.} \tl_clear_new:N\knowledge_configuration_pending_tl \newrobustcmd\knowledgeconfigure[1]{ \keys_set:nn{ knowledge~configuration~options }{#1} @@ -928,9 +963,13 @@ \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_diagnosehelp_bool +\bool_set_true:N\knowledge_configuration_diagnosehelp_bool +\KnowledgeConfigureBooleanOption[\knowledge_configuration_diagnosehelp_bool]{diagnose~help} +\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} \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 @@ -1441,20 +1480,20 @@ \bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}} } \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: } \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}} } \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} -\NewDocumentCommand\scopeLabel{m}{ +\KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{label~scope} +\NewDocumentCommand\knowledgelabel{m}{ \kl_hide_begin: \bool_if:NTF \knowledge_configuration_label_autoscope_bool @@ -1464,7 +1503,8 @@ \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 \cs_new:Npn\knowledge_latex_label:n{ \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\label } @@ -1481,8 +1521,8 @@ \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} } \NewKAuxCommand\KAuxScopeNewInstance{mmm} {Package~scope:~Declares~a~new~instance~of~a~scope.} @@ -1539,7 +1579,7 @@ {\scope_area_pop:n{##1}} {}} \kutils_secure_latex_command:N\label - \let\label\scopeLabel + \let\label\knowledgelabel } \NewDocumentCommand\ScopeActivate{}{ \cs_gset_eq:NN\ScopeActivate\relax @@ -1593,9 +1633,9 @@ {\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}} -\KAuxBefore{\KAuxProcess{init}} +\KAuxBefore{\IfKAuxReadyTF{\KAuxProcess{init}}{}} \KAuxInit{} \KAuxAfter{\KnowledgeDiagnoseOutput} \iow_new:N\knowledge_diagnosefile_iow @@ -1638,6 +1678,21 @@ \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~*} @@ -1645,6 +1700,8 @@ \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{} @@ -1845,15 +1902,13 @@ 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, - 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}}}, } \NewKAuxCommand\KAuxKnowledge{mmmm} @@ -1910,7 +1965,7 @@ \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}}} @@ -1926,6 +1981,7 @@ \kl_hide_end: } \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{ @@ -1936,6 +1992,9 @@ \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 @@ -1946,40 +2005,42 @@ % \__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\knowledge_knowledge_barnotation_firstline:n{} +\cs_new:Npn\knowledge_knowledge_barnotation_nextlines:n{} +\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 } \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:} } -\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 } \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:} + {\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}}} \NewDocumentCommand\knowledgestyle{ s m m } { \kl_hide_begin: \group_begin: @@ -2030,9 +2091,9 @@ {} % \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{ @@ -2132,14 +2193,18 @@ \tl_gnew:Nn\knowledge_display_code_tl{INTERNAL~ERROR~DISPLAY~CODE} \NewDocumentCommand\klTKS{}{\knowledge_klTKS:nnn} \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} @@ -2161,7 +2226,9 @@ \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:} } \cs_set:Npn\knowledge_kl_find_recursion_exceeded:TF{ @@ -2171,20 +2238,22 @@ \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: } } \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 @@ -2192,6 +2261,9 @@ \l_tmpa_tl \knowledge_kl_key_tl} } +\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 @@ -2202,16 +2274,18 @@ {}} {} } -\cs_new:Npn\knowledge_kl_find_scopetag_tmpa:n{ - \knowledge_kl_find_scopetag:Nn\l_tmpa_tl -} \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:} } @@ -2221,6 +2295,7 @@ } \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 @@ -2233,13 +2308,13 @@ {#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 - }{}} + \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 @@ -2253,13 +2328,14 @@ \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 @@ -2335,7 +2411,7 @@ {\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}{} @@ -2607,7 +2683,7 @@ \NewKnowledgeParamBool*{uppercase}\kl_uppercase_bool \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} @@ -3198,7 +3274,7 @@ \expandafter{\tl_to_str:n{#1}}} \newcommand\robustdisplaybracket[1] {[\robustdisplay{#1}]} - +\knowledgedirective{ignore}{} \ExplSyntaxOff \IfKnowledgePaperModeTF{ \knowledgestyle{kl unknown}{} -- cgit v1.2.3