I guess the best approach here would be to replace ALL instances of that word with the specified word. Then you should replace the text inside of the A Tag with the original word
So using your example:
**Original text**:
Tim's favorite [color] is color.
Color is also Bill's favorite.
**Interim step text**:
Tim's favorite [blue] is blue.
Blue is also Bill's favorite.
**Converted text**:
Tim's favorite [color] is blue.
Blue is also Bill's favorite.
The problems you will run into with this method are:
- Being context aware so you capitalize the replaced word in the second sentance. (Your description of the problem didn't cover that but the example did)
- Recognizing all links regardless of structure via regular expression
As such I haven't include any code, but I hope this puts you on the right track.