How can I count the number of leading spaces and not all spaces as with the use of \str_count_spaces
?
Concretly I would like to read a content line by line and for each line of input I would use the indentation to build the corresponding output.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\seq_new:N \l__pmbc_words_seq
\tl_new:N \l__pmbc_one_temp_tl
\NewExpandableDocumentCommand{\nbleadingsp}{m} {
\projetmbc_nbleadingsp:n { #1 }
}
\cs_new:Nn \projetmbc_nbleadingsp:n {
% ...
}
\ExplSyntaxOff
\begin{document}
\nbleadingsp{ 1space}
\nbleadingsp{ two spaces}
\nbleadingsp{ 2 * 2 spaces}
\end{document}
\nbleadingsp{ a}
or\nbleadingsp{ a}
or\nbleadingsp{ a}
will all have one single space token. – Phelype Oleinik Aug 13 '20 at 16:33\nbleadingsp
to be in the argument of another command. Or globally changing the category code of the space, which would break so many things… – egreg Aug 13 '20 at 16:43