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

Commit 235a2cf

Browse files
committed
Allow asterisks in
1 parent 390bdd1 commit 235a2cf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

javascript.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,17 @@ sf.format = function() {
228228
for (var i = 0; i < comments[c].childNodes.length; i++) {
229229
if (comments[c].childNodes[i].nodeName == "#text") {
230230
var p = document.createElement("span");
231-
p.innerHTML = " " + sf.parse(comments[c].childNodes[i].data);
231+
p.innerHTML = " " + sf.parse(comments[c].childNodes[i].data) + " ";
232232
comments[c].childNodes[i].replaceWith(p);
233233
}
234234
}
235235
}
236236
}
237237

238238
sf.parseMD = function(text) {
239+
// Allow asterisks in code block
240+
text = text.replace(/[`].+[`]/gm, function(x) {return x.replace(/\*/gm, "&ast;")});
241+
239242
text = text.replace(/```((.|\n*)*?)```/gm, "<code>$1</code>");
240243
text = text.replace(/`(.*?)`/g, "<code>$1</code>");
241244

@@ -244,7 +247,7 @@ sf.parseMD = function(text) {
244247
text = text.replace(/\*(.*?)\*/g, "<i>$1</i>");
245248

246249
// Don't format links that already have a tag with them
247-
// Sorry, I cheated with both Stackoverflow :\
250+
// Sorry, I cheated with Stackoverflow :\
248251
// https://stackoverflow.com/a/8943487
249252
text = text.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, "<a href='$1'>$1</a>");
250253

0 commit comments

Comments
 (0)