Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 256b1e7

Browse files
committed
More bug fixes
1 parent 14884b1 commit 256b1e7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

javascript.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,17 @@ sf.format = function() {
228228
}
229229

230230
sf.parseMD = function(text) {
231+
text = text.replace(/```((.|\n*)*?)```/gm, "<code>$1</code>");
232+
text = text.replace(/`(.*?)`/g, "<code>$1</code>");
233+
231234
// Bold, then italics
232235
text = text.replace(/\*\*(.*?)\*\*/g, "<b>$1</b>");
233236
text = text.replace(/\*(.*?)\*/g, "<i>$1</i>");
234237

235-
text = text.replace(/```((.|\n*)*?)```/gm, "<code>$1</code>");
236-
text = text.replace(/`(.*?)`/g, "<code>$1</code>");
237-
238238
// Don't format links that already have a tag with them
239-
text = text.replace(/(https:|http:|www\.)([^\"\>\<]*$)/gm, "<a href='$1$2'>$1$2</a>");
239+
// Sorry, I cheated with both Stackoverflow :\
240+
// https://stackoverflow.com/a/8943487
241+
text = text.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, "<a href='$1'>$1</a>");
240242

241243
return text;
242244
}

0 commit comments

Comments
 (0)