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

Commit 8723014

Browse files
committed
Parsing bugs
1 parent 198b9f3 commit 8723014

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

javascript.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var tags = [
5050
"name": "link",
5151
"tag": "link",
5252
"src": "https://raw.githubusercontent.com/Remix-Design/RemixIcon/master/icons/Editor/link.svg",
53-
"fillers": ["[link=https://example.com", "]Link[/link]"],
53+
"fillers": ["[link=https://example.com]", "[/link]"],
5454
"formatter": function(part1, part2) {
5555
return "<a href='" + part1 + "' target='_newtab'>" + part2 + "</a>";
5656
}
@@ -130,6 +130,10 @@ setTimeout(function() {
130130
textarea.selectionEnd
131131
);
132132

133+
if (selection.length == 0) {
134+
selection = "text";
135+
}
136+
133137
// Generate new text, if just 1 filler, ex [br], don't attempt
134138
// to use second part.
135139
var newText = textarea.value.substring(0, textarea.selectionStart)
@@ -179,7 +183,7 @@ function format() {
179183
comments[c].style.marginLeft = "3px";
180184
}
181185

182-
comments[c].innerHTML = parse(comments[c].innerText);
186+
comments[c].innerHTML = parse(comments[c].innerHTML);
183187
}
184188
}
185189

@@ -205,7 +209,8 @@ function parse(text) {
205209

206210
// If just 1 tag (Ex [br])
207211
if (tags[t].fillers.length > 1) {
208-
regex += "(.*)";
212+
// Lazy matching (?)
213+
regex += "(.*?)";
209214

210215
// Second part of tag
211216
regex += startBracket;

loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Loads javascript onto page
2+
// Dirty method.
23
{var s = document.createElement('script');
34
s.src = chrome.extension.getURL('smod.js');
45
(document.head||document.documentElement).appendChild(s);}

0 commit comments

Comments
 (0)