This is another chapter of the story "how to use a moodle database for my purposes". The accepted answer to this question gives a very effective way to retrieve informations from an exercise database structured as follows
\begin{multi}{}
Text
\item first answer
\item* correct anser
...
\end{multi}
Now, the object retrieved as "nth answer" contains all kind of spacing, for instance
\item
first answer
will store the \par.
I would like to erase all kind of "blank" spaces before the start of the actual aswer, for editing purpose.
An example for the Wipet answer which does not fit in a comment. If I set
\documentclass{article}
\usepackage{getitems}
\begin{document}
\def\item{\futurelet\next \itemA}
\def\itemA{\ifx\next\par \expandafter\itemB \fi}
\long\def\itemB#1{\item}
\def\A{
A}
\def\B{%
B}
X\expandafter\item\A X
X\expandafter\item\B X
\end{document}
The output is
X
AX
XBX
So \expandafter\item\A does not work (it includes a linebreak before A) while \expandafter\item\B works (it does not include a linebreak before B)

\NewDocumentCommand{\HEAD}{ m }{\tl_head:N { #1 }}and\NewDocumentCommand{\TAIL}{ m }{\tl_tail:N { #1 }}and then\HEAD\A\TAIL\A, with\Aas in the question, and does not work (whil it works with\B) – user126154 May 16 '22 at 21:39\def\A{...}\def\B{...}, i.e. what is around them? How the\itemis defined? Full example means that it can be used without adding another context which I don't know. Full example is full document. – wipet May 17 '22 at 04:33\item, included blank lines, and this fact bugs my final rendering, – user126154 May 17 '22 at 06:39\def\Anor\def\B. So, I still don't know, how looks like your full example with\def\Aand\def\Band\expandafter\item\Aand\expandafter\item\B. You are talking that it does not work and I am unable to construct a full example which documents your claim. I am waiting for full example or we close this discussion. – wipet May 17 '22 at 10:43\def\A{but should be\def\A{%. The\itemmacro skips only\partokens, no spaces. My firs idea were that\itemis followed by the real text, so there is no spaces immediately after\item. But the space were propagated from expanded macro\Ain your example. – wipet May 17 '22 at 14:20