Conversion of user-defined theorem environments to LaTeX

If I have some user-defined theorem environments, then I find the conversion to LaTeX is suboptimal. For example, if I have

<new-remark|setup|Setup>

Then it will convert a setup environment into something like

{\setup{This is a setup.}}

My current workaround is to define a new commend \newcommand\setup[2][]{\begin{env-setup}[{#1}]{#2}\end{env-setup}} along with \newtheorem{env-setup}{Setup} in my customized preamble. This works most of time, but sometimes it would break (for example, if it contains tikz-cd, then ampersands & in tikz-cd will break). I wonder whether there is a more reliable way?