Short answer
At this time it's not possible to set new custom URL mapping for Google Docs editors.
Explanation
Google Docs editors URL format change was announced at the beginning of 2015. If the Google Apps administrator set the URL mapping before the change were rolled out to the organization it should continue to work but if he didn't he can't create a custom URL mapping for Google Docs editors:
Alternative
None that I know about.
References
Google Docs editors URL format change - Google Apps update alerts
There are no tricks, just built-in tools and scripts.
Manual conversion
To turn http://example.com into http://example.com, select it and press Ctrl-K (or right-click and choose Link).
This will be a hassle if you pasted in several dozens of these. Then a script is preferable.
Conversion with a script
I wrote two functions, for two different conversions:
- <a href="http://example.com">link text</a> to <a href="http://example.com">link text</a>
- <a href="http://example.com">link text</a> to link text
Both are added to the document menu by the onOpen function.
The approach is the same in both cases, the details vary in step 3.
- Use Body.findText method to find the elements containing the text of interest. (This search method has some support of regular expressions, although not much.)
- Obtain the text string from each matching element:
.getElement().asText().getText()
- Use the JavaScript regex engine to search (and substitute if necessary).
- Finally, linkify by using Text.setLinkUrl method.
function linkify() {
var body = DocumentApp.getActiveDocument().getBody();
var range = body.findText("<a[^<]*</a>");
while (range) {
var nextRange = body.findText("<a[^<]*</a>", range);
var elem = range.getElement().asText();
var str = elem.getText();
var re = /href=(\W)(.*?)\1/g;
var result = re.exec(str);
while (result) {
var index = result.index;
var url = result[2];
elem.setLinkUrl(index+6, index+url.length+5, url);
result = re.exec(str);
}
range = nextRange;
}
}
function replaceWithLink() {
var body = DocumentApp.getActiveDocument().getBody();
var range = body.findText("<a[^<]*</a>");
while (range) {
var nextRange = body.findText("<a[^<]*</a>", range);
var elem = range.getElement().asText();
var str = elem.getText();
var result = /<a[^<]*<\/a>/.exec(str);
while (result) {
var link = result[0];
var index = result.index;
var url = /href=(\W)(.*)\1/.exec(link)[2];
var text = />(.*)</.exec(link)[1];
elem.replaceText(link, text);
elem.setLinkUrl(index, index+text.length-1, url);
str = str.replace(link, text);
result = /<a[^<]*<\/a>/.exec(str);
}
range = nextRange;
}
}
function onOpen() {
DocumentApp.getUi()
.createMenu('Custom')
.addItem('Recognize href as a link', 'linkify')
.addItem('Replace <a> elements with links', 'replaceWithLink')
.addToUi();
}
Best Answer
It seems that right now, in 2018, it's the default behavior.
The link detection gets triggered when you enter a space or press enter after pasting or writing the URL.
So, if you paste a URL that has space at the end of it - it won't automatically detect it (at least not at first), and will treat it as simple text. For example "https://google.com ".
You can verify this setting under Tools --> Preferences: