Let's say I have a document, and I want to colorize the first word of each line. That is to say, when a word is the first word of a line, it should be replaced by \textcolor{red}{[the word]}.
This question had answered this in part, using discretionary ligatures, but this does not work when you begin a paragraph with a word, as well as the spacing problem.
I would think that a Lua(La)TeX solution is possible. Is there a way to go through each (typeset) line, get the first word of each (typeset) line and then replace that word with a colorized version using LuaTeX? That way, one doesn't have to manually color words, whether or not they occur at a spot for a discretionary ligature.
(a phrase in parens)
make(
red ora
red or(a
red?