aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src
diff options
context:
space:
mode:
authorGravatar KillyMXI2017-07-16 00:59:10 +0300
committerGravatar KillyMXI2017-07-17 15:07:27 +0300
commit17681e690eb83f02f07a3d119c9117f241ba26c1 (patch)
tree2678c7a1fdffad05556b2efcebcb34bba372da4e /juick-www/src
parent63f80733d90a87f44219a110148bfb9a0e207164 (diff)
www: fix js markup parser:
prevent high-priority rules to run again after low priority rules
Diffstat (limited to 'juick-www/src')
-rw-r--r--juick-www/src/main/js/killy/index.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/juick-www/src/main/js/killy/index.js b/juick-www/src/main/js/killy/index.js
index 136a5825..5f59225c 100644
--- a/juick-www/src/main/js/killy/index.js
+++ b/juick-www/src/main/js/killy/index.js
@@ -22,12 +22,13 @@ function formatText(txt, rules) {
.sort(([r1,m1],[r2,m2]) => (r1.pr - r2.pr) || (m1.index - m2.index));
if (matches && matches.length > 0) {
let [rule, match] = matches[0];
+ let subsequentRules = rules.filter(r => r.pr >= rule.pr);
let idStr = `<>(${nextId()})<>`;
let outerStr = txt.substring(0, match.index) + idStr + txt.substring(rule.re.lastIndex);
let innerStr = (rule.brackets)
- ? (() => { let [l ,r ,f] = rule.with; return l + ft((f ? f(match[1]) : match[1]), rules) + r; })()
+ ? (() => { let [l ,r ,f] = rule.with; return l + ft((f ? f(match[1]) : match[1]), subsequentRules) + r; })()
: match[0].replace(rule.re, rule.with);
- return ft(outerStr, rules).replace(idStr, innerStr);
+ return ft(outerStr, subsequentRules).replace(idStr, innerStr);
}
return txt;
}