How to split token list by any char, like a raw document text?
For example, i have a code to bold first word in macro argument. Macro is correctly works for direct using from code, like \bfirst{word word word}, but my macro can't separate words if i use token list variable.
My code:
% XeLaTeX Document
\documentclass[a4paper]{extarticle}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=modern]{russian}
\defaultfontfeatures{Ligatures={TeX},Renderer=Basic}
\setmainfont{Arial}
\usepackage{expl3}
\ExplSyntaxOn
% Bold first word in macro argument
\seq_new:N \l_mytest_bstring_seq
\tl_new:N \l_mytest_bfirst_tl
\NewDocumentCommand{\bfirst}{ m }
{
\seq_set_split:Nnn \l_mytest_bstring_seq { ~ } { #1 }
\seq_pop_left:NN \l_mytest_bstring_seq \l_mytest_bfirst_tl
\textbf{\l_mytest_bfirst_tl} ~
\seq_use:Nn \l_mytest_bstring_seq { ~ }
}
% TL can't be splitted?
\tl_new:N \l_test_example_tl
\tl_set:Nn \l_test_example_tl {TL\ word~word\ word...}
\NewDocumentCommand{\tlbfirst}{}
{
\par\bfirst{\l_test_example_tl}
\par\bfirst{\tl_use:N \l_test_example_tl}
}
\ExplSyntaxOff
\begin{document}
\par\bfirst{Word word word...}
\tlbfirst
\end{document}
Result:

How to make same result for raw text and token list?


\NewDocumentCommandexcept for passing control to an internal function”. It shouldn't be used when it shouldn't be used (like in this cases). But there are many times when the interface macro is not just passing an argument to an internal macro but rather do some checks and more that (in my opinion, shouldn't be inside an expl3 macro because it doesn't belong to that level). It's just that I think that sentence is not good as a general rule. – Manuel Nov 12 '14 at 15:24