In math articles, sometimes there might be a lot of composed phrases like $R$-module, $r$-$K$-linear, etc., and in some cases it could be confusing whether a - is for hyphenation or is it just a normal - in the phrases.
It would seem inappropriate to completely suppress word break in these phrases (with \mbox, for example) since some of them might be quite long. For now I use the NON-BREAKING HYPHEN (U+02011) though to ensure that the breaking point is not at those - which are part of the phrases, so there is no risk that one shall misread them as a hyphen char. However, it is still strange to see something like $r$-$k$-li- at the end of a line.
In these cases, is it possible to make the hyphen char - in gray (for example as \textcolor{gray}{-}) or some other style, globally, so as to differ from the normal -?
At first this seems to me an easy question, but after searching around on this site it turns out that one seems to have very little control over the hyphen chars (pre-break, post-break and no-break, according to the question given below). Shouldn't we have full access to them and can change them to whatever we want?
I've checked in particular this question, but the solution seems to aim at changing the hyphen char only locally (not sure if I understood the usage of \discretionary correctly). Also, it seems that the treatment for hyphen char differs under different engines, thus if it is too much to ask for a universal way to achieve this, I hope that the solution (if exists) can at least work for LuaLaTeX.
\hyphenchar\tenrm="7B. Perhaps that is already sufficient for you? – Heiko Theißen Jul 02 '22 at 14:00\textcolor{gray}{-}? I'm always gettingMissing number, treated as zero. – Jinwen Jul 02 '22 at 14:10\textcolor. – Heiko Theißen Jul 02 '22 at 14:11pre_output_filtercallback to "manually" replace the hyphenations (if you set it to some unique unused character, it can be distinguished from the normal hyphens) with differently-colored characters, not sure if it can actually work however. – user202729 Jul 02 '22 at 15:16fontspec. – Jinwen Jul 02 '22 at 15:57