Ok, \starttexdefinition allows blanks, apparently just like setups.
But, it still fails exactly like the version with \def
\setuphead[chapter][
before={Before: \structureuservariable{author}\blank},
beforesection={Beforesection: \structureuservariable{author}\blank},
insidesection={Insidesection: \structureuservariable{author}\blank},
after={After: \structureuservariable{author}\blank},
]
\def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
\define[2]\myChapterCommand{\structureuservariable{author}\blank #1\space#2}
%\def\myChapterCommand#1#2{\structureuservariable{author}\blank #1\space#2} % does not work
% \starttexdefinition myChapterCommand #1 #2 % doesn't work either, but at least blanks should work
% \structureuservariable{author}
% Test
% \blank
% #1\space#2
% \stoptexdefinition
\starttext
\myChapterCommand{1}{asdf}
\startchapter[title=First][author=First Author]
\input knuth
\stopchapter
\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter
\setuphead[chapter]
[
before=,after=,beforesection=,insidesection=,
command=\myChapterCommand,
]
\startchapter[title=Third][author={Third Author}]
\input knuth
\stopchapter
\stoptext
Von: denis.maier@unibe.ch
Gesendet: Dienstag, 12. September 2023 17:48
An: ntg-context@ntg.nl
Betreff: [NTG-context] Using structureuservariables before the heading
Hi,
is it possible to access a structureuservariable before the heading's title ?
Using the <before> key does not seem to work.
As an aside, I've tried to use the < command > key to provide my own command, but while \define works here (but ignores \blank), \def gives me an error.
Why is that?
How would you add blanks to a user-defined command?
Best,
Denis
\setuphead[chapter][
before={Before: \structureuservariable{author}\blank},
beforesection={Beforesection: \structureuservariable{author}\blank},
insidesection={Insidesection: \structureuservariable{author}\blank},
after={After: \structureuservariable{author}\blank},
]
\def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
\define[2]\myChapterCommand{\structureuservariable{author}\blank #1\space#2}
%\def\myChapterCommand#1#2{\structureuservariable{author}\blank #1\space#2} % does not work
\starttext
\macro{1}{2}
\startchapter[title=First][author=First Author]
\input knuth
\stopchapter
\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter
\setuphead[chapter]
[
before=,after=,beforesection=,insidesection=,
command=\myChapterCommand,
]
\startchapter[title=Third][author=Third Author]
\input knuth
\stopchapter
\stoptext