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)


\footnotetakes (effectively) two arguments not one:-) see the usage in my update answer. – David Carlisle Dec 01 '15 at 12:59reledmac-distribution? Possibly with the option to letreledmactrigger it in a similar manner as e.g.imakeidxdoes for the index-processing? But any automatisation of this problem would be very nice! – Florian Dec 01 '15 at 13:36