# The environ package eats a space

I am using the environ package to collect the body of an environment to be used later. It appears that the environenvironment gobbles the trailing space. For example,

\documentclass{article}

\usepackage{environ}

\NewEnviron{myenviron}{\BODY}
\begin{document}
A \begin{myenviron}B\end{myenviron} C

X\begin{myenviron}Y\end{myenviron}Z
\end{document}


gives me A BC and XYZ, but I would like A B C and XYZ. What is the proper way to get the trailing space back?

I just looked at the source code and the answer is on line 7

\environfinalcode{\ignorespacesafterend}


so I can fix the problem with \environfinalcode{}, but I would prefer a less global change.

The \environfinalcode is executed if not overridden explicitly with the final optional argument.

\documentclass{article}

\usepackage{environ}

\NewEnviron{myenviron}{\BODY}[]

\begin{document}
A \begin{myenviron}B\end{myenviron} C

X\begin{myenviron}Y\end{myenviron}Z
\end{document}