I will propose this as a solution, although I will not guarantee that it does not contain a quoting error.
define(`UL',`<ul>IT($@)<\ul>')dnl
define(`LI',`ifelse(`$1',`', `', `<li>`$1'<\li>')')dnl
define(`IT',`ifelse(`$#', `0',, `$#', `1',`LI(`$1')',
`LI(`$1')IT(shift($@))')')dnl
dnl
UL(foo,bar,baz)
UL(`UL',`LI',`IT')
UL(``UL'',``LI'',``IT'')
For posterity, here is my original solution which certainly does contain a quoting error:
define(`UL',`<ul>IT($@)<\ul>')dnl
define(`LI',`ifelse(`$1',`', `', `<li>$1<\li>')')dnl
define(`IT',`ifelse(`$#', `0',, `$#', `1',`LI(`$1')',
`LI(`$1')IT(shift($*))')')dnl
dnl
UL(foo,bar,baz)
UL(`UL',`LI',`IT')
UL(``UL'',``LI'',``IT'')
In the first solution, the final invocation of UL
is not exactly what I expect, but I'm so unsure of m4 quoting rules that I really don't know what to expect, so I suspect there is a quoting error. Help appreciated.