summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-not.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-not.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-not.mkiv405
1 files changed, 273 insertions, 132 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-not.mkiv b/Master/texmf-dist/tex/context/base/strc-not.mkiv
index 4b033cbf9e7..45e37b276f5 100644
--- a/Master/texmf-dist/tex/context/base/strc-not.mkiv
+++ b/Master/texmf-dist/tex/context/base/strc-not.mkiv
@@ -17,6 +17,12 @@
\unprotect
+% this needs a further cleanup ...
+%
+% -- set breakpoin in descriptions
+% -- reset after trialtypesetting
+% -- that way we can trick the symbol space
+
% obsolete
\let\autopostponenotes\relax
@@ -97,7 +103,7 @@
\newtoks\tobeprocessednotes
-\def\processnotes#1% #1: \macro that uses \currentnote
+\unexpanded\def\processnotes#1% #1: \macro that uses \currentnote
{\def\doprocesssomenote##1{\edef\currentnote{##1}\let\currentdescription\currentnote#1}%
\the\tobeprocessednotes}
@@ -150,13 +156,12 @@
%D Are quite ligitimate, we default to a simple one 20\% of the
%D text width.
-\def\setupnotes
+\unexpanded\def\setupnotes
{\dodoubleargument\getparameters[\??vn]}
\setupnotes
[\c!location=\v!page,
\c!way=\v!by\v!part,
- \c!sectionnumber=\v!no,
%\c!conversion=,
\c!rule=\v!on,
\c!before=\blank,
@@ -186,34 +191,29 @@
\c!interaction=\v!yes,
%\c!factor=,
%\c!scope=, % \v!text \v!page
-\c!prefixconnector=.,
-\c!prefix=\v!no,
- \c!next=\autoinsertnextspace, % new, experimental with startnotes
+ \c!prefixconnector=.,
+ %\c!next=\autoinsertnextspace
+ \c!prefix=\v!no,
+ %\c!continue=\v!no,
\c!n=1]
+\setupnotes
+ [\c!expansion=\v!no,
+ \c!xmlsetup=,
+ \s!catcodes=,
+ \c!saveinlist=\v!yes]
+
\def\@@defaultnotedefloc{\v!inleft}
\def\@@defaultnotedefdis{\!!zeropoint}
-% also s!root
-%
-% \definedescription
-% [\??vn\??vn]
-% [\c!location=\@@defaultnotedefloc,
-% \c!distance=\@@defaultnotedefdis,
-% \c!width=\v!fit,
-% \c!headstyle=\noteparameter\c!style,
-% \c!headcolor=\noteparameter\c!color,
-% \c!before=,
-% \c!after=]
-
-\def\startnotedef{\resetdescriptions\csname\e!start\??vn\??vn\currentnote\endcsname}
-\def\stopnotedef {\csname\e!stop \??vn\??vn\currentnote\endcsname}
+\unexpanded\def\startnotedef{\resetdescriptions\csname\e!start\??vn\??vn\currentnote\endcsname}
+\unexpanded\def\stopnotedef {\csname\e!stop \??vn\??vn\currentnote\endcsname}
\def\currentnoteins{\csname\??vn:\currentnote\endcsname}
\newtoks \everysetupnote
-\def\definenote
+\unexpanded\def\definenote
{\dodoubleempty\dodefinenote}
\def\dodefinenote[#1][#2]%
@@ -227,12 +227,13 @@
[\c!location=\@@defaultnotedefloc,
\c!distance=\@@defaultnotedefdis,
\c!width=\v!fit,
- \c!headstyle=\noteparameter\c!style,
- \c!headcolor=\noteparameter\c!color,
-\s!handler=\v!note,
+ \c!headstyle=\noteparameter\c!style, % hm
+ \c!headcolor=\noteparameter\c!color, % hm
+ \s!handler=\v!note,
\c!text=,
\c!before=,
\c!after=]%
+ \doredefinenotecommands\currentnote
\setupenumerations
[\currentnote]
[\s!parent=\??vn\currentnote,
@@ -242,12 +243,35 @@
\getparameters
[\??vn\currentnote]
[\s!parent=\??vn,#2]%
- \definestructurecounter
- [\currentnote]%
+% \definestructurecounter
+% [\currentnote]%
\ctxlua{structure.notes.define("\currentnote","insert",\number\csname\??vn:\currentnote\endcsname)}%
\the\everysetupnote
\dochecknote}
+% \starttext
+% text \startfootnote Test.\stopfootnote
+% test \footnote{xxxx} \subfootnote{xxxx}
+% test \footnote{xxxx} \subfootnote{xxxx}
+% \stoptext
+
+\def\dodoredefinenotecommands#1#2#3%
+ {\unexpanded\expandafter\def\csname\e!start#3#1\expandafter\endcsname\expandafter
+ {\expandafter\dosingleempty\csname\s!do\e!start#3#1\endcsname}%
+ \unexpanded\expandafter\def\csname\s!do\e!start#3#1\expandafter\endcsname
+ \expandafter[\expandafter##\expandafter1\expandafter]\expandafter##\expandafter2\csname\e!stop#3#1\endcsname
+ {\begingroup
+ \doenumerationinit{#1}{#2}{#3}%
+ \@@notemakedescription[##1]{}{##2}%
+ \endgroup}}
+
+\def\doredefinenotecommands#1%
+ {\normalexpanded{\noexpand\dodoredefinenotecommands{#1}{1}{}}%
+ \let\@@subslevel\empty
+ \dostepwiserecurse{2}{\descriptionparameter\c!levels}{1}
+ {\normalexpanded{\noexpand\dodoredefinenotecommands{#1}{\recurselevel}{\@@subslevel\v!sub}}%
+ \edef\@@subslevel{\@@subslevel\v!sub}}}
+
\let\setupnotedefinition\setupenumerations
\appendtoks
@@ -258,8 +282,7 @@
% \dochecknote
% \to \everysetupnote
-
-\def\setupnote
+\unexpanded\def\setupnote
{\dodoubleempty\dosetupnote}
\def\dosetupnote[#1][#2]%
@@ -271,16 +294,20 @@
\dochecknote}
\appendtoks
- \letvalue{\??vn\c!rule:\currentnote}\normalnoterule % hm
+ \setvalue{\??vn\c!rule:c:\currentnote}{\normalnoterule}% hm
+ \letvalue{\??vn\c!rule:a:\currentnote}\v!left
\to \everysetupnote
\appendtoks
- \processaction
- [\noteparameter\c!rule]
- [ \v!on=>\letvalue{\??vn\c!rule:\currentnote}\normalnoterule,
- \v!off=>\letvalue{\??vn\c!rule:\currentnote}\relax,
- \s!default=>\letvalue{\??vn\c!rule:\currentnote}\relax,
- \s!unknown=>\setvalue{\??vn\c!rule:\currentnote}{\noteparameter\c!rule}]%
+ \expanded{\processallactionsinset
+ [\noteparameter\c!rule]}
+ [ \v!on=>\setvalue{\??vn\c!rule:c:\currentnote}{\normalnoterule}, % no let as it can be changed afterwards
+ \v!normal=>\setvalue{\??vn\c!rule:c:\currentnote}{\normalnoterule},
+ \v!left=>\setvalue{\??vn\c!rule:a:\currentnote}{l2r},
+ \v!right=>\setvalue{\??vn\c!rule:a:\currentnote}{r2l},
+ \v!off=>\letvalue{\??vn\c!rule:c:\currentnote}\relax,
+ \s!default=>\letvalue{\??vn\c!rule:c:\currentnote}\relax,
+ \s!unknown=>\setvalue{\??vn\c!rule:c:\currentnote}{\noteparameter\c!rule}]%
\to \everysetupnote
\appendtoks
@@ -333,8 +360,8 @@
\setvalue{\??vn @\v!page }{\setnotelocation\plusone}
\setvalue{\??vn @\v!columns }{\setnotelocation\plustwo}
-\setvalue{\??vn @\v!firstcolumn}{\setnotelocation\plusthree}
-\setvalue{\??vn @\v!lastcolumn }{\setnotelocation\plusfour}
+\setvalue{\??vn @\v!lastcolumn }{\setnotelocation\plusthree}
+\setvalue{\??vn @\v!firstcolumn}{\setnotelocation\plusfour}
\setvalue{\??vn @\v!none }{\setnotelocation\plusfive}
\setvalue{\??vn @\v!text }{\setnotelocation\plusfive \setnoteformatting\plusone} % test
\setvalue{\??vn @\v!high }{\setnoteposition\plusone}
@@ -378,15 +405,8 @@
\ifnotelimit
\global\dimen\currentnoteins\dimexpr\noteparameter\c!height*\scratchcounter\relax
\fi
- % distance
- \begingroup
- \setbox\scratchbox\vbox
- {\forgetall
- \noteparameter\c!before
- \placenoterule
- \noteparameter\c!after}%
- \global\skip\currentnoteins\ht\scratchbox
- \endgroup
+ % distance -> tricky as this might depend on a font switch so we need a fast checker
+ \dosetnotedistance
% play safe
\ifnum\noteparameter\s!noteloc=\plusfive
\ctxlua{structure.notes.setstate("\currentnote","store")}%
@@ -396,10 +416,28 @@
\global\skip \currentnoteins\zeropoint
\fi}
-% \def\checknotes
-% {\processnotes\dochecknote}
+\def\dosetnotedistance
+ {\begingroup
+ \setbox\scratchbox\vbox
+ {\forgetall
+ \dontcomplain
+ \noteparameter\c!before
+ \placenoterule
+ \noteparameter\c!after}%
+ \global\skip\currentnoteins\ht\scratchbox
+ \endgroup}
-\let\checknotes\relax % experiment, avoiding this saves a lot of time
+% \def\checknotes % no longer needed
+% {\processnotes\dochecknote}
+%
+% \def\checknotedistances
+% {\processnotes\dosetnotedistance}
+%
+% fails but not that much needed anyway:
+%
+% \appendtoks
+% \checknotedistances
+% \to \everyglobalbodyfont
% D When \type{n} exceeds~1, footnotes are typeset in
% D multi||columns, using the algoritm presented on page~397
@@ -423,20 +461,30 @@
%D runs). Let's just reserve a few points, that probably match
%D those of the stretch component.
-\def\placenoterule
- {\getvalue{\??vn\c!rule:\currentnote}}
+%D A bit messy:
-\def\normalnoterule
+\unexpanded\def\placenoterule
+ {\bgroup
+ \setupalign[\getvalue{\??vn\c!rule:a:\currentnote}]%
+ \righttoleft
+ \getvalue{\??vn\c!rule:c:\currentnote}%
+ \par
+ \egroup}
+
+\unexpanded\def\normalnoterule
{\ifvmode
- \color
- [\noteparameter\c!rulecolor]
- {\hrule\!!width .2\hsize\!!height\noteparameter\c!rulethickness\!!depth \zeropoint}%
+ \dontleavehmode \blackrule
+ [ \c!color=\noteparameter\c!rulecolor,
+ \c!width=.2\hsize,
+ \c!height=\noteparameter\c!rulethickness,
+ \c!depth=\zeropoint]%
+ \endgraf
\kern\strutdepth
\fi}
\ifx\setnotehsize\undefined
- \def\setnotehsize{\hsize\noteparameter\c!width\relax} % can be overloaded
+ \unexpanded\def\setnotehsize{\hsize\noteparameter\c!width\relax} % can be overloaded
\fi
@@ -499,68 +547,105 @@
%D functionality.
%D The next implementation runs on top of enumerations (only in \MKIV).
+%D
+%D \starttyping
+%D \setupenumerations
+%D [footnote]
+%D [ style=\type{(es)},
+%D headstyle=\type{(hs)}]
+%D
+%D \setupnote
+%D [footnote]
+%D [ style=\type{(s)},
+%D command=\type{(c)},
+%D textcommand=\type{(tc)},
+%D textstyle=\type{(ts)},
+%D numberstyle=\type{(ns)},
+%D numbercommand=\type{(nc)}]
+%D
+%D \setuplayout[backspace=6cm,marginwidth=cm,width=middle]
+%D
+%D \starttext
+%D \dorecurse{9}{This\footnote{Hello World #1} is a test.\par }
+%D \stoptext
+%D \stoptyping
% TODO: \ifnotesenabled
\newif\ifnotesymbol \notesymboltrue
-\def\setnote [#1]{\getvalue{#1}}
-\def\setnotetext[#1]{\global\settrue\skipnoteplacement\getvalue{#1}}
+\newconditional\skipnoteplacement
+
+\unexpanded\def\setnote [#1]{\getvalue{#1}}
+\unexpanded\def\setnotetext[#1]{\global\settrue\skipnoteplacement\getvalue{#1}}
\def\domovednote#1#2#3#4%
{\ifcase\ctxlua{structure.notes.deltapage("#1",#2)}\or\symbol[#3]\or\symbol[#4]\fi}
-\setvalue{\??dd:\v!note:\s!handler }{\@@doenumerationhandler}
-\setvalue{\??dd:\v!note:\s!handler:\s!do }{\@@somenotedescription}
-\setvalue{\??dd:\v!note:\s!handler:\s!start}{\@@startsomenotedescription}
+\setvalue{\??dd:\v!note:\s!handler:\s!text }{\@@donotetext}
+\setvalue{\??dd:\v!note:\s!handler:\s!number}{\@@donotenumber}
+\setvalue{\??dd:\v!note:\s!handler }{\@@donotehandler}
+\setvalue{\??dd:\v!note:\s!handler:\s!do }{\@@somenotedescription}
+\setvalue{\??dd:\v!note:\s!handler:\s!start }{\@@startsomenotedescription}
+
+\let\@@donotehandler\@@dodescriptionhandler
\def\@@somenotedescription {\@@notemakedescription}
\def\@@startsomenotedescription{\@@notemakedescription}
-\newconditional\skipnoteplacement
-
-\def\@@notemakedescription[#1]#2#3% todo ... proper [key=value] etc
+\def\@@notemakedescription[#1]#2#3%
{\ifnotesenabled
- \begingroup
- \doenumerationcheckconditions
- \let\currentnote\currentdescriptionmain
- \dodescriptioncomponent[\c!reference=#1,\c!label={\descriptionparameter\c!text},\c!title={#3},\c!bookmark=,][]%
- \xdef\currentnotenumber{\ctxlua{structure.notes.store("\currentnote",\currentdescriptionnumberentry)}}%
- \settrue\processingnote
- \ifconditional\skipnoteplacement
- \globallet\lastnotesymbol\dolastnotesymbol
+ \edef\currentdescriptionreference{#1}%
+ \iftrialtypesetting
+ \doenumerationcheckconditions
+ \let\currentnote\currentdescriptionmain
+ \typesetdummynotesymbol
\else
- \iftypesettinglines % otherwise problems with \type <crlf> {xxx}
- \ignorelines % makes footnotes work in \startlines ... \stoplines
- \fi
- \ifnotesymbol
- \dolastnotesymbol
- \else
- \unskip\unskip
+ \begingroup
+ \doenumerationcheckconditions
+ \let\currentnote\currentdescriptionmain
+ \dodescriptioncomponent[\c!reference=#1,\c!label={\descriptionparameter\c!text},\c!title={#3},\c!list=,\c!bookmark=,][]%
+ \xdef\currentnotenumber{\ctxlua{structure.notes.store("\currentnote",\currentdescriptionnumberentry)}}%
+ \settrue\processingnote
+ \ifconditional\skipnoteplacement
\globallet\lastnotesymbol\dolastnotesymbol
+ \else
+ \iftypesettinglines % otherwise problems with \type <crlf> {xxx}
+ \ignorelines % makes footnotes work in \startlines ... \stoplines
+ \fi
+ \ifnotesymbol
+ \dolastnotesymbol
+ \else
+ \unskip\unskip
+ \globallet\lastnotesymbol\dolastnotesymbol
+ \fi
\fi
+ \ifconditional\postponingnotes % todo: per note class
+ \global\settrue\postponednote
+ \else\ifconditional\inlocalnotes % todo: per note class
+ \global\settrue\postponednote
+ \else
+ \handlenoteinsert\currentnote\currentnotenumber
+ \fi\fi
+ \endgroup
\fi
- \ifconditional\postponingnotes
- \global\settrue\postponednote
- \else
- \handlenoteinsert\currentnote\currentnotenumber
- \fi
- \ifconditional\skipnoteplacement \else
- \kern\notesignal\relax % \relax is needed to honor spaces
- \iftrialtypesetting \else \global\setfalse\skipnoteplacement \fi
- \fi
- \endgroup
+ \fi
+ \ifconditional\skipnoteplacement
+ \global\setfalse\skipnoteplacement
+ \else
+ \kern\notesignal\relax % \relax is needed to honor spaces
\fi}
-\def\dolastnotesymbol{\typesetsomenotesymbol\currentnote\currentnotenumber}
+\def\dolastnotesymbol
+ {\typesetsomenotesymbol\currentnote\currentnotenumber}
-\def\dotypesetsomenotesymbol#1#2%
+\def\dotypesetsomenotesymbol#1#2% running text
{\dodonotesymbol
{\synchronizesomenotesymbol{#1}{#2}%
\ctxlua{structure.notes.number("\currentnote",\currentnotenumber)}% \currentdescriptionnumberentry
\domovednote{#1}{#2}\v!previouspage\v!nextpage}}
-\def\typesetsomenotesymbol#1#2%
+\unexpanded\def\typesetsomenotesymbol#1#2% running text
{\removeunwantedspaces
\doifitalicelse\/\donothing % Charles IV \footnote{the fourth}
\ifdim\lastkern=\notesignal
@@ -572,10 +657,35 @@
{\directgotobox{\dotypesetsomenotesymbol{#1}{#2}}[page(\ctxlua{structure.notes.getnumberpage("#1",\number#2)})]}% f:
\globallet\lastnotesymbol\relax}
+\unexpanded\def\typesetdummynotesymbol % temp hack
+ {\removeunwantedspaces
+ \doifitalicelse\/\donothing % Charles IV \footnote{the fourth}
+ \ifdim\lastkern=\notesignal
+ \dodonotesymbol{\kern\noteparameter\c!distance}% gets the font right, hack !
+ \fi
+ \nobreak
+ \hbox to .5em{}%
+ \globallet\lastnotesymbol\relax}
+
\def\currentnotedescriptiontext % todo: can be other number
{\ctxlua{structure.notes.title("\currentnote",\currentdescriptionnumberentry)}}
-\def\currentnoteenumerationfullnumber
+\def\@@donotetext
+ {\ifconditional\enumerationnumberenabled
+ \iftrialtypesetting
+ \doenumerationfullnumber\showdntext
+ \doenumerationcouplingsymbol
+ \else
+ \doenumerationregistercoupling
+ \doenumerationfullnumber\showdntext
+ \doenumerationcouplingsymbol
+ \fi
+ \else
+ \doenumerationfullnumber\showdnpuretext
+ \fi}
+
+% \def\currentnoteenumerationfullnumber
+\def\@@donotenumber
{\doifelse{\noteparameter\c!interaction}\v!no
{\docurrentnoteenumerationfullnumber}%
{\directgotobox
@@ -584,7 +694,8 @@
\def\docurrentnoteenumerationfullnumber
{\noteparameter\c!numbercommand
- {\ctxlua{structure.notes.number("\currentnote",\currentdescriptionnumberentry)}%
+ {\dosetnoteattributes\c!numberstyle\c!numbercolor
+ \ctxlua{structure.notes.number("\currentnote",\currentdescriptionnumberentry)}%
\domovednote\currentdescription\currentdescriptionnumberentry\v!nextpage\v!previouspage}}
\def\synchronizesomenotesymbol#1#2% called more often than needed
@@ -596,6 +707,7 @@
\the\everybeforenoteinsert
\insert\currentnoteins\bgroup
\the\everyinsidenoteinsert
+ \doprocesslocalsetups{\noteparameter\c!setups}% experimental
\handlenoteitself{#1}{#2}%
\egroup
\the\everyafternoteinsert
@@ -605,8 +717,12 @@
{\edef\currentdescription{#1}%
\edef\currentnote{#1}%
\edef\currentdescriptionnumberentry{#2}%
- \let\currentdescriptiontext\currentnotedescriptiontext
- \let\currentenumerationfullnumber\currentnoteenumerationfullnumber
+ \edef\currentdescriptionlistentry{\ctxlua{tex.write(structure.notes.listindex("#1",#2))}}%
+ % as we can have collected notes (e.g. in tables) we need to recover
+ % \currentdescriptionattribute and \currentdescriptionsynchronize
+ \reinstatedescriptionnumberentry\currentdescriptionlistentry % we could store the number in the entry
+ %
+ \dontcomplain % should be done in startstoreddescription instead
\dostartstoreddescription\begstrut\currentnotedescriptiontext\endstrut\dostopstoreddescription}
\def\dostartstoreddescription
@@ -669,6 +785,8 @@
\fi
\to \everyinsidenoteinsert
+% not: \appendtoks \setnotehsize \to \everyinsidenoteinsert (spoils columns)
+
\let\lastnotesymbol\relax
%D \macros
@@ -681,7 +799,7 @@
%D
%D This command is implemented rather straightforward as:
-\def\notesymbol
+\unexpanded\def\notesymbol
{\dodoubleempty\donotesymbol}
\def\donotesymbol[#1][#2]%
@@ -709,29 +827,33 @@
%
% \dorecurse{6}{\input tufte\footnote{\input ward \input tufte \relax}}
-\def\placenoteinserts
+\unexpanded\def\placenoteinserts
{\processnotes\doplacenoteinserts}
-\def\unvboxed {\ifvmode\unvbox \else\box \fi}
-\def\unvcopied{\ifvmode\unvcopy\else\copy\fi}
+\unexpanded\def\unvboxed {\ifvmode\unvbox \else\box \fi}
+\unexpanded\def\unvcopied{\ifvmode\unvcopy\else\copy\fi}
\def\doplacenoteinserts
{\relax\ifdim\ht\currentnoteins>\zeropoint\relax
\ifnum\noteparameter\s!noteloc=\plusfive
\else
- \endgraf
- \ifvmode
- \whitespace
- \noteparameter\c!before
- \fi
+ \endgraf
+ \ifvmode
+ \whitespace
+ \noteparameter\c!before
+ \fi
+% \bgroup
+% \setupalign[\noteparameter\c!align]%
\placenoterule % alleen in ..mode
+% \par
+% \egroup
\bgroup
\setnotebodyfont
\setbox\scratchbox\hbox
{% this should be checked, smells like a mix-up
% does not split: \ifcase\noteparameter\c!n\unvbox\else\box\fi\currentnoteins
\ifcase\noteparameter\c!n\relax
- \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins
+ \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins % is this needed?
\or
\iftrialtypesetting\copy\else\box\fi\currentnoteins
\obeydepth % (a) added , since split footnotes will not align properly
@@ -834,26 +956,32 @@
\def\defaultnotewidth{\makeupwidth} % {\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}
-\def\startlocalnotes
+\newconditional\inlocalnotes
+
+\unexpanded\def\startlocalnotes
{\dosingleempty\dostartlocalnotes}
\def\dostartlocalnotes[#1]%
{\def\localnoteslist{#1}%
+ \settrue\inlocalnotes
\processcommacommand[\localnoteslist]\dodostartlocalnotes}
-\def\stoplocalnotes
- {\processcommacommand[\localnoteslist]\dodostoplocalnotes}
+\unexpanded\def\stoplocalnotes
+ {\processcommacommand[\localnoteslist]\dodostoplocalnotes
+ \setfalse\inlocalnotes}
\def\dodostartlocalnotes#1%
- {\savestructurecounter[#1]%
- \resetstructurecounter[#1]%
+ {\doifnot{\noteparameter\c!continue}\v!yes
+ {\savestructurecounter[#1]%
+ \resetstructurecounter[#1]}%
\ctxlua{structure.notes.save("#1","store")}}
\def\dodostoplocalnotes#1%
- {\restorestructurecounter[#1]%
+ {\doifnot{\noteparameter\c!continue}\v!yes
+ {\restorestructurecounter[#1]}%
\ctxlua{structure.notes.restore("#1")}}
-\def\placelocalnotes
+\unexpanded\def\placelocalnotes
{\dodoubleempty\doplacelocalnotes}
\def\doplacelocalnotes[#1][#2]%
@@ -903,10 +1031,10 @@
%D
%D \showsetup{placefootnotes}
-\def\placebottomnotes
+\unexpanded\def\placebottomnotes
{\processnotes\placenoteinserts}
-\def\placenotes
+\unexpanded\def\placenotes
{\dodoubleempty\doplacenotes}
\def\doplacenotes[#1][#2]%
@@ -990,13 +1118,13 @@
% is this ok? endnotes and such
- \def\fakenotes
+ \unexpanded\def\fakenotes
{\ifhmode\endgraf\fi\ifvmode
\calculatetotalclevernoteheight
\ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
\fi}
- \def\fakepagenotes
+ \unexpanded\def\fakepagenotes
{\ifhmode\endgraf\fi\ifvmode
\calculatetotalpagenoteheight
\ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
@@ -1006,15 +1134,18 @@
\def\doaddtototalnoteheight#1%
{\ifdim\ht#1>\zeropoint
- \advance\totalnoteheight\ht #1%
- \advance\totalnoteheight\skip#1%
+ \ifcase\count#1\else
+ % todo: divide by count
+ \advance\totalnoteheight\ht #1%
+ \advance\totalnoteheight\skip#1%
+ \fi
\fi}
\def\docalculatetotalnoteheight
{\ifcase\clevernotes % tricky here ! ! ! to be sorted out ! ! !
\doaddtototalnoteheight\currentnoteins
\else
- \doaddtototalnoteheight\currentbackupnoteins
+% \doaddtototalnoteheight\currentbackupnoteins
\fi}
\def\docalculatetotalclevernoteheight
@@ -1101,34 +1232,44 @@
%D Compatibility macros:
- \def\setupfootnotedefinition{\setupnotedefinition [\v!footnote]}
- \def\setupfootnotes {\setupnote [\v!footnote]}
-%unexpanded \def\footnote {\setnote [\v!footnote]}
-\unexpanded \def\footnotetext {\setnotetext [\v!footnote]}
- %def\note {\dodoubleempty\notesymbol [\v!footnote]} % alleen footnote
- \def\placefootnotes {\dodoubleempty\doplacefootnotes [\v!footnote]}
- \def\placelocalfootnotes {\dodoubleempty\doplacelocalfootnotes[\v!footnote]}
- \def\startlocalfootnotes {\startlocalnotes [\v!footnote]} % alleen footnote
- \def\stoplocalfootnotes {\stoplocalnotes }
+\unexpanded\def\setupfootnotedefinition{\setupnotedefinition [\v!footnote]}
+\unexpanded\def\setupfootnotes {\setupnote [\v!footnote]}
+%unexpanded\def\footnote {\setnote [\v!footnote]}
+\def\footnotetext {\setnotetext [\v!footnote]}
+%unexpanded\def\note {\dodoubleempty\notesymbol [\v!footnote]} % alleen footnote
+\unexpanded\def\placefootnotes {\dodoubleempty\doplacefootnotes [\v!footnote]}
+\unexpanded\def\placelocalfootnotes {\dodoubleempty\doplacelocalfootnotes[\v!footnote]}
+\unexpanded\def\startlocalfootnotes {\startlocalnotes [\v!footnote]} % alleen footnote
+\unexpanded\def\stoplocalfootnotes {\stoplocalnotes }
\def\doplacefootnotes [#1][#2]{\ifsecondargument\placenotes [#1][#2,\c!height=\textheight]\else\placenotes [#1]\fi}
\def\doplacelocalfootnotes[#1][#2]{\ifsecondargument\placelocalnotes[#1][#2,\c!height=\textheight]\else\placelocalnotes[#1]\fi}
-\def\note{\dodoubleempty\donote}
+\unexpanded\def\note{\dodoubleempty\donote}
\def\donote[#1][#2]{\ifsecondargument\donotesymbol[#1][#2]\else\secondargumenttrue\donotesymbol[\v!footnote][#1]\fi}
+%D Goodies:
+%D
+%D \starttyping
+%D \dorecurse {100} {
+%D test \footnote{\doifnoteonsamepageelse[footnote]{ibidem}{aaa}}
+%D }
+%D \stoptyping
+
+\def\doifnoteonsamepageelse[#1]{\ctxlua{structure.notes.doifonsamepageasprevious("#1")}}
+
%D New trickery:
\def\ownnotesymbol#1% #1 gets number passed
{\executeifdefined{\??vn::\currentnote}\empty}
-\def\setnotesymbol[#1]#2#3%
+\unexpanded\def\setnotesymbol[#1]#2#3%
{\prewordbreak % prevent lookback
\setgvalue{\??vn::#1}{#3}
\dolastnotesymbol}
-\def\ownnote[#1]#2#3#4%
+\unexpanded\def\ownnote[#1]#2#3#4%
{\setnotesymbol[#1]{#2}{#3}%
\setnotetext [#1]{#4}}