I have the following html in a page:
<p>foo
<br>bar
<!--additional br elements of variable number-->
<br>https://example.com
<!--additional br elements of variable number-->
<br>baz
</p>
The link appears in plain text and I need to linkify it.
This does NOT yield any match:
document.evaluate( '//*[contains(text(),"https")]' ,document,
null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
If I use '//text()[contains(.,"https")]'
I get the entire text but not a reference to a DOM element that I can then modify (for adding an <a>
element around it so that is becomes clickable.)
How can I select the element containing this plain text URL in a way that I can then modify it?