I want to make the character >
active only in text mode (to create markdown-style block quotes) but not in math mode. I know the \mathcode`>="8000
way to make a character active only in math mode, but what about the reverse? I tried \ifmmode
but that doesn't seem to work.
Here's what I have now, having to escape it as \>
in math mode.
\usepackage[many]{tcolorbox}
\makeatletter
\newtcolorbox{QuoteBlock}{
blanker,
before skip=\topsep,
after skip=\topsep,
borderline west={2pt}{0pt}{black!50!white},
breakable,
left=\parindent,
}
\begingroup
\catcode`\>=\active
\catcode`\^^M=\active
\gdef>#1^^M{%
\begin{QuoteBlock}%
\noindent\@ifnextchar\par\@gobble\relax#1
\end{QuoteBlock}
}
\endgroup
\def\>{\string>}
\AtBeginDocument{\catcode`\>=\active \catcode`\^^M=\active}
\makeatother
\begin{document}
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
\[x\>0\]
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
\end{document}