How to underline a given word

Hi,
I am working my way through codemirror 6 and wondering if it possible to underline a given word within the editor. If so, what would be the easiest way of doing this.

Mark decorations can be used to underline something. See also the decoration example.

Can we also achieve the same functionality in codemirror5?

Yes, see markText.