I figured out a minimal working example. If \item good
has the same starting word in the search list, the document doesn't compile.
If I write something like \item foo
, the document compiles.
\documentclass{article}
\usepackage{xesearch}
\begin{document}
\SearchList{l}{Better}{good job}
\begin{itemize}
\item good
\end{itemize}
happy good job
\end{document}
The error message is
! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.17 \end{itemize}
Is there any way to fix the issue? My real file has a lot of itemize environments and I hope to run xesearch on arbitary text outside of the itemize environments.
I'm also happy to know how to debug this error, like what the text looks like after the search and replacement.
\AddToHook{env/itemize/begin}{\XeTeXinterchartokenstate0 }
. But on the whole that looks rather fragile and experimental.job
and expand commands partly. That can break in various places. You can also try to stop the search withgood\vphantom{}
.