In order to improve the \sameword
feature of reledmac, I would like to find a way to automatically apply a command to every word. For example, in plain TeX,
\def\foo#1{#1 (#1)}
foo bar foo bar foo bar foo, foo? foo. foo;
\end
should be automatically transformed to
\def\foo#1{#1 (#1)}
\foo{foo} \foo{bar} \foo{foo} \foo{bar} \foo{foo} \foo{bar} \foo{foo}, \foo{foo}? \foo{foo}. \foo{foo};
\end
My constraints are:
- excluding the punctuation mark
- excluding some commands (for example
foo\footnote{bar}
should become\foo{foo}\footnote{bar}
and not\foo{foo\footnote{bar}}
) - if possible, working with pdfTeX, XeTeX and LuaTeX, but a LuaTeX-only solution would be nice.
- using any already existing LaTeX package (but a pure plainTeX is also accepted)
Best Answer
It would be so easy to break this, but..