Skip to content

Commit 35aa796

Browse files
authored
linkify links in <li> elements
1 parent bc9289e commit 35aa796

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

journal.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,17 @@ Clearly, I should start with (8) because it will help me come up with other thin
457457
ga('create', 'UA-103157758-1', 'auto');
458458
ga('send', 'pageview');
459459

460+
function urlify(text) {
461+
var urlRegex = /(https?:\/\/[^\s]+)/g;
462+
return text.replace(urlRegex, function(url) {
463+
return '<a href="' + url + '">' + url + '</a>';
464+
})
465+
466+
}
467+
468+
var all = document.getElementsByTagName("li");
469+
for (var i=0, max=all.length; i < max; i++) {
470+
var element = all[i]; element.innerHTML = urlify(element.innerHTML);
471+
}
472+
460473
</script>

0 commit comments

Comments
 (0)