Action Directory / Reopen Link
InstallScans the current line for any Markdown inline link or image link, and returns a list of results. Choose one to reopen in Safari. Ideal for Split View on iPad.
Shared by viticci
Script
var matches = []
var re = /!?\[([^\]]+)\]\(([^\s]+)(\s"[^\)]*")?\)/g;
var line = editor.getSelectedLineRange();
var extract = editor.getTextInRange(line[0], line[1]);
while (match = re.exec(extract)) {
matches.push(match[2]);
}
if (matches.length == 0) {
ui.alert('No inline links have been found in the current line.', 'No Links')
return;
}
else if (matches.length >= 1) {
ui.list('Matched Links', matches, reOpen);
function reOpen(selectedValues) {
if (!selectedValues) { //user pressed Cancel
return;
}
var text = selectedValues.join('\n');
app.openURL(text);
}
}