xparse
right now but not so close to expl3
, I'm trying to dig deeper. Below is my MWE, using key-value arguments with the second one is a list of items separated by commas. The list is printed normally when I passed it directly to the
\DrawList
command, which has a \SplitList
processor and a \ProcessList
command. However, if the text is parsed by the \keys_define
before being splitted, it seems to ignore the comma and the processor cannot split it at all.How can I make it print like the
\DrawList
command? It's also great if anyone has a better alternative to make the interface easier. Thank you all.Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{xparse}\ExplSyntaxOn\NewDocumentCommand\DrawList{>{\SplitList{,}}m}{\begin{itemize}\ProcessList{#1}{\item}\end{itemize}}\keys_define:nn {module_name}{,1 .tl_set:N = \__title,2 .tl_set:N = \__list}\NewDocumentCommand \TitleAndList { O{} }{\group_begin:\keys_set:nn {module_name}{#1}\tl_if_empty:NF {\__title}{%\__title :\par}\tl_if_empty:NF {\__list}{%\DrawList{\__list}}\group_end:}\ExplSyntaxOff\begin{document}\DrawList{{First item, with a comma}, {Second item}}---\TitleAndList[1=Include,2={{First item, with a comma}, {Second item}}
Code: Select all
Code, edit and compile here:
\seq_new:N \list_sequence\NewDocumentCommand\DrawList{m}{\seq_set_split:Nnn \list_sequence{,}{#1}\begin{itemize}\seq_map_function:NN \list_sequence \item\end{itemize}}