diff options
Diffstat (limited to 'tex/context/base/strc-lnt.mkvi')
-rw-r--r-- | tex/context/base/strc-lnt.mkvi | 101 |
1 files changed, 96 insertions, 5 deletions
diff --git a/tex/context/base/strc-lnt.mkvi b/tex/context/base/strc-lnt.mkvi index 9b93ba07f..4160360d2 100644 --- a/tex/context/base/strc-lnt.mkvi +++ b/tex/context/base/strc-lnt.mkvi @@ -50,6 +50,7 @@ \unexpanded\def\strc_linenotes_start#1[#2]#3% {\global\advance\c_strc_linenotes\plusone + \keepunwantedspaces \strc_linenotes_indeed{#1}{#2}{#3}% \strc_linenotes_traced{#2}% \startline[#2]} @@ -57,19 +58,109 @@ \unexpanded\def\strc_linenotes_stop[#1]% {\stopline[#1]} -\unexpanded\def\strc_linenotes_indeed#1#2#3% will be redone +\let\m_page_lines_previous_to \relax +\let\m_page_lines_previous_from\relax + +\let\m_page_lines_current_to \relax +\let\m_page_lines_current_from \relax + +\newconditional\c_page_lines_current_to +\newconditional\c_page_lines_current_from + +\installcorenamespace{linenotespreviousfrom} +\installcorenamespace{linenotespreviousto} + +\letvalue\??linenotespreviousfrom\empty +\letvalue\??linenotespreviousto \empty + +\def\page_lines_in_from{\in[lr:b:\currentlinenotereference]} +\def\page_lines_in_to {\in[lr:e:\currentlinenotereference]} + +\unexpanded\def\strc_linenotes_range_normal#1% order + {\doifreferencefoundelse{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from + \ifconditional\c_page_lines_current_from + \xdef\m_page_lines_current_from{\currentreferencelinenumber}% + \doifreferencefoundelse{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to + \ifconditional\c_page_lines_current_to + \xdef\m_page_lines_current_to{\currentreferencelinenumber}% + \page_lines_in_from + \ifx\m_page_lines_current_from\m_page_lines_current_to \else + \endash + \page_lines_in_to + \fi + \else + \page_lines_in_from + \fi + \else + \page_lines_in_from + \fi} + +\unexpanded\def\strc_linenotes_range_sparse#1% order + {\doifreferencefoundelse{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from + \ifconditional\c_page_lines_current_from + \xdef\m_page_lines_current_from{\currentreferencelinenumber}% + \doifreferencefoundelse{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to + \ifconditional\c_page_lines_current_to + \xdef\m_page_lines_current_to{\currentreferencelinenumber}% + \ifx\m_page_lines_previous_from\m_page_lines_current_from + \ifx\m_page_lines_previous_to\m_page_lines_current_to + \notationparameter\c!compressseparator + \else + \page_lines_in_from + \fi + \else + \page_lines_in_from + \ifx\m_page_lines_current_from\m_page_lines_current_to + \else + \endash + \page_lines_in_to + \fi + \fi + \else + \page_lines_in_from + \fi + \else + \ifx\m_page_lines_previous_from\m_page_lines_current_from + \notationparameter\c!compressseparator + \else + \page_lines_in_from + \fi + \fi} + +\let\currentlinenotereference\empty + +\unexpanded\def\strc_linenotes_indeed#1#2#3% {\begingroup % we keep things local so we can use it as regular note too - \unexpanded\def\linenotelinenumber##1{\inlinerange[#2]}% ##1 == order -% \setupnotation[#1][\c!numbercommand=\linenotelinenumber]% todo: deep hook -% \setupnote[#1][\c!textcommand=\gobbleoneargument]% todo: deep hook \edef\currentnotation{#1}% + \edef\currentlinenotereference{#2}% + \xdef\m_page_lines_previous_from{\csname\??linenotespreviousfrom\ifcsname\??linenotespreviousfrom\currentnotation\endcsname\currentnotation\fi\endcsname}% + \xdef\m_page_lines_previous_to {\csname\??linenotespreviousto \ifcsname\??linenotespreviousto \currentnotation\endcsname\currentnotation\fi\endcsname}% + \doifelse{\notationparameter\c!compress}\v!yes + {\let\linenotelinenumber\strc_linenotes_range_sparse}% + {\let\linenotelinenumber\strc_linenotes_range_normal}% \let\currentnote\currentnotation \letnotationparameter\c!numbercommand\linenotelinenumber% todo: deep hook \letnoteparameter \c!textcommand \gobbleoneargument % todo: deep hook - \relax\getvalue{\??linenote#1}{#3}% + \getvalue{\??linenote\currentnotation}{#3}% + \expandafter\glet\csname\??linenotespreviousfrom\currentnotation\endcsname\m_page_lines_current_from + \expandafter\glet\csname\??linenotespreviousto \currentnotation\endcsname\m_page_lines_current_to \endgroup} +% where to hook this one in? resetcounter has no hook: + +\unexpanded\def\doresetlinenotecompression#1% \strc_linenotes_reset_previous + {\expandafter\glet\csname\??linenotespreviousfrom#1\endcsname\empty + \expandafter\glet\csname\??linenotespreviousto #1\endcsname\empty} + +\definesymbol + [\v!compressseparator] + [\space\hbox{\vl\thinspace\vl}] + +\setupnotations + [%c\compress=\v!no, + \c!compressseparator=\symbol\v!compressseparator] + \let\strc_linenotes_traced\gobbleoneargument \def\strc_linenotes_traced_indeed#1% |