Since it was pointed out that redefining \item can be dangerous in strange interaction between `mdframed` and `\item`, I am wondering if there are going to be problems with this solution.
My goal is to replace:
\begin{enumerate}[label={(\alph*)}]
\MyItem \TextA
\MyItem \TextB
\end{enumerate}

with (i.e., only the environment name is changed):
\begin{MyEnumerate}[label={(\alph*)}]
\MyItem \TextA
\MyItem \TextB
\end{MyEnumerate}
to obtain an mdframe around each item:

The solution as below seems to work, at least for this test case. So, is this way of using \MyItem instead of \item have hidden dangers that are not obvious in this test case.
Notes:
- This seems a lot like Box around a few items in an itemize environment, but is different in that I want this frame around each item, and do need to use
mdframedas opposed to just atikzrectangle.
Code:
\documentclass{article}
\usepackage{etoolbox}% for toggles
\usepackage{enumitem}
\usepackage{mdframed}
\newcommand{\TextA}{%
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed accumsan hendrerit velit, vitae ultrices sapien porta nec.
}%
\newcommand{\TextB}{%
Duis blandit tempus placerat.
Nulla vitae erat ante. Nulla facilisi.
Aliquam tristique interdum suscipit.
Duis posuere orci vel velit suscipit in porttitor purus eleifend.
}%
\newcommand{\MyItem}{\item}
\newtoggle{FirstItem}%
\toggletrue{FirstItem}%
\newenvironment{MyEnumerate}[1][]{%
\renewcommand{\MyItem}{%
\iftoggle{FirstItem}{%
\global\togglefalse{FirstItem}
%--------- start new frame
\begin{mdframed}[skipbelow=2pt]%
\begin{enumerate}[#1,series=MySeries]%
}{%
\end{enumerate}%
\end{mdframed}%
%--------- end previous frame and start new one
\begin{mdframed}[skipbelow=2pt]%
\begin{enumerate}[#1,resume*=MySeries]%
}%
\item%
}%
}{%
\end{enumerate}%
\end{mdframed}% --------- end last frame
\global\toggletrue{FirstItem}%
}%
\begin{document}\noindent
\textbf{enumerate:}
\begin{enumerate}[label={(\alph)}]
\MyItem \TextA
\MyItem \TextB
\end{enumerate}
%
\medskip
\textbf{MyEnumerate:}
\begin{MyEnumerate}[label={(\alph)}]
\MyItem \TextA
\MyItem \TextB
\end{MyEnumerate}
\end{document}
mydoublelinewhich will be passed before every item is set. – Marco Daniel May 18 '12 at 20:55\itemwhich according to the linked question is dangerous. Or, perhaps I misunderstood what you meant. – Peter Grill May 18 '12 at 20:58mdframedloadsetoolbox) – Marco Daniel May 18 '12 at 21:14