Add italic/bold markdown syntax
authorChip Black <bytex64@bytex64.net>
Mon, 10 Jan 2011 10:17:46 +0000 (02:17 -0800)
committerChip Black <bytex64@bytex64.net>
Mon, 10 Jan 2011 10:17:46 +0000 (02:17 -0800)
www/js/blerg.js

index 737d84c..2ee3467 100644 (file)
@@ -252,6 +252,10 @@ function mangleRecord(record, template) {
     // Turn markdown links into links
     record.data = record.data.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)]*?)?)\)/, '$1<a href="$3">$2</a>');
 
+    // Turn *foo* into italics and **foo** into bold
+    record.data = record.data.replace(/(\s)\*\*([^*]+)\*\*(\s)/, '$1<b>$2</b>$3');
+    record.data = record.data.replace(/(\s)\*([^*]+)\*(\s)/, '$1<i>$2</i>$3');
+
     // Turn refs and tags into links
     record.data = record.data.replace(/(\s|^)#(\w+)/g, '$1<a href="#tag/$2">#$2</a>');
     record.data = record.data.replace(/(\s|^)@(\w+)/g, '$1<a href="#$2">@$2</a>');