I'm having trouble with the xparse package's environment creating commands. What I'd like to do in the end is write my own list environment. The toy example below shows my current problem: the list shows up, but some extra text is getting appended during the closing of the environment. I "fixed" it by using the \newenvironment command, but I was hoping to use the argument processing options that xparse provides.
In the cljlists.sty package:
\NewDocumentEnvironment{xparselist}{}{BEGIN!\begin{itemize}}{\end{itemize}END!}
\newenvironment{newlist}{BEGIN!\begin{itemize}}{\end{itemize}END!}
In the document:
\subparagraph*[short]{Second Sub-Paragraph}
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
\begin{newlist}
\item item
\end{newlist}
\begin{xparselist}{mandatory}
\item item
\end{xparselist}
This outputs: (sorry the image got chopped for being new, but about like this...)
Second Sub-Paragraph text...text BEGIN!
- item
END!BEGIN!
- item
END! shortSecond Sub-Paragraph
I'm not sure why the arguments provided to \subparagraph are being used by the blahblahblah environment when it closes. I have redefined \subparagraph using xparse's \DeclareDocumentCommand. I don't have this problem when I declare another command using xparse, however. Have I missed something important in the documentation?
EDIT: here's complete minimal copy of the code which reproduces the problem, including requests from the comments.
The problem should be more apparent now that I can attach photos. The list environment I created using xparse, is typesetting some text immediately after the environment closes, which appears to come from the arguments I provide to the subparagraph command.
Document:
\documentclass{article}
\usepackage{toylists}
\begin{document}
\subparagraph{title}
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
\begin{newenvlist}
\item item
\end{newenvlist}
\begin{xparselist}
\item item
\end{xparselist}
\end{document}
Package:
\ProvidesPackage{toylists}[2011/03/08 xparse list example]
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{xparse}
\DeclareDocumentCommand{\subparagraph}{s o m}{\textit{#3}}
\NewDocumentEnvironment{xparselist}{}{%
\begin{itemize}}{%
\end{itemize}}
\newenvironment{newenvlist}{%
\begin{itemize}}{%
\end{itemize}}
Output:

xparse, but to be sure I could do with a full example (starting\documentclassand ending\end{doccument}): I'm a bit lost with the description of what you've actually tried. – Joseph Wright♦ Mar 4 '11 at 21:25%characters at the end of lines, which are used to prevent spurious spaces appearing. However, that does not just apply toxparse. – Joseph Wright♦ Mar 4 '11 at 22:21\ExplSyntaxOn...\ExplSyntaxOffto avoid worrying about spaces" in this case ? – Bruno Le Floch Mar 5 '11 at 15:52\listfilesin your preamble and have a look at the log file to find out... – Seamus Mar 8 '11 at 16:20