Here I make the .
active inside \tab
and restore it when I am done. Inside \tab
, the .
can become \item
if the next token is a not a nested \tab
and it becomes \relax
if the next token is a nested \tab
. I keep track of the nesting level with a simple counter, and only restore the catcode
12 definition of .
when the nesting level reaches back to zero.
I have EDITED to allow switching between text mode and math mode processing.
In my RE-EDIT, I have resolved the issue of the stray $$
lines which popped up in math mode (requiring a countermanding \vspace
), so that no \vspace
s are presently required, and the spacing in math mode matches that of a true itemize
environment.
In my MWE, I have placed text and math versions side-by-side in minipages for comparison.
\documentclass{article}
\newcounter{nestlevel}
\def\mathitemize{\def\DOL{$}}
\def\textitemize{\def\DOL{}}
\textitemize
\let\svdot.
\catcode`.=\active
\newcommand\tab{\stepcounter{nestlevel}\catcode`.=\active\tabhelper}
\newcommand\tabhelper[1]{%
\def\tabdone{F}%
\let.\dotparse%
\begin{itemize}%
\item\DOL#1\if F\tabdone\DOL\fi\gdef\tabdone{T}%
\end{itemize}%
\addtocounter{nestlevel}{-1}%
\if0\thenestlevel\catcode`.=12\let.\svdot\fi%
}
\makeatletter
\def\dotparse{\if F\tabdone\DOL\fi\def\tabdone{F}\@ifnextchar\tab\relax\xitem}
\makeatother
\def\xitem{\item\DOL}
\catcode`.=12
\parskip 1em
\begin{document}
\begin{minipage}{.4\textwidth}
\textitemize\tab{a.\tab{b1.\tab{b11.\tab{b112.b113}}.b2}.c.\tab{1.2}.d}
\end{minipage}
\begin{minipage}{.4\textwidth}
\mathitemize\tab{a.\tab{b1.\tab{b11.\tab{b112.b113}}.b2}.c.\tab{1.2}.d}
\end{minipage}
\end{document}

I would add in passing that, as is, the OP has prohibited the use of the dot as part of his argument, since his requested syntax will interpret the .
as a call for a new \item
or nested itemize
. If one really does need a dot as part of the data stream, it would make sense to choose a different character than .
as the parsing separator, which is easy enough to accomplish by way of substitution in the MWE.