I'm looking to do the following:
- Locate links in the document
- Select them and change their styling
So far, I have:
var body = DocumentApp.getActiveDocument().getBody();
var text = body.editAsText().getText();
var words = text.split(' ');
for (var i = 0; i < words.length; i++) {
var word = words[i];
// Doesn't work because word isn't a Text object
// word.getLinkUrl();
}
I understand how to iterate over the words in a paragraph. The issue is determining if the text is a link. I can't use the getText()
method because that converts the Text object to a string (prohibiting me from testing if a word is a link via the getLinkUrl()
method.
I've found a number of "find and replace" solutions. I can't use findText()
because I can't predict the strings in the links. For instance, Resources could point to example.com.
Any help would be much appreciated.