X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjs%2Fblerg.js;h=83483fa4b0e4ec671fa2ea6afb5030642cfe3a49;hb=481423bac9915a431020b5e5e7672300d4adb3b0;hp=83a8a88683f523c3554b05f72e5a49a8fab816af;hpb=cdcf2e46dea2a2cc210caeb10a951ea8cf5d0e26;p=blerg.git
diff --git a/www/js/blerg.js b/www/js/blerg.js
index 83a8a88..83483fa 100644
--- a/www/js/blerg.js
+++ b/www/js/blerg.js
@@ -404,6 +404,25 @@ function mangleRecord(record, template) {
l = l.replace(/(\s|^)(https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/([^\s"]*[^.!,;?()\s])?)?)/g, '$1$2');
// Turn markdown links into links
+ var re;
+
+ // Craft a regex that finds URLs that end in the extensions specified by BlergMedia.audioExtensions.
+ re = new RegExp('(\\s|^)\\[([^\\]]+)\\]\\((https?:\\/\\/[a-zA-Z0-9.-]*[a-zA-Z0-9]\\/[^)"]*?\\.(' + BlergMedia.audioExtensions.join('|') + '))\\)', 'g');
+ l = l.replace(re, '$1$2 ');
+
+ // Ditto, but use the extended markdown link syntax to specify the format
+ re = new RegExp('(\\s|^)\\[([^\\]]+)\\]\\((https?:\\/\\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\\/[^)"]*?)?)\\s+audio:(' + BlergMedia.audioExtensions.join('|') + ')\\)', 'g');
+ l = l.replace(re, '$1$2 ');
+
+ // Craft a regex that finds URLs that end in the extensions specified by BlergMedia.videoExtensions.
+ re = new RegExp('(\\s|^)\\[([^\\]]+)\\]\\((https?:\\/\\/[a-zA-Z0-9.-]*[a-zA-Z0-9]\\/[^)"]*?\\.(' + BlergMedia.videoExtensions.join('|') + '))\\)', 'g');
+ l = l.replace(re, '$1$2 ');
+
+ // Ditto, but use the extended markdown link syntax to specify the format
+ re = new RegExp('(\\s|^)\\[([^\\]]+)\\]\\((https?:\\/\\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\\/[^)"]*?)?)\\s+video:(' + BlergMedia.videoExtensions.join('|') + ')\\)', 'g');
+ l = l.replace(re, '$1$2 ');
+
+ // Regular markdown links
l = l.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/g, '$1$2');
// Turn *foo* into italics and **foo** into bold