]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Bolded wasn't matching rest of text.
authorWill Budicm <redacted>
Sat, 2 Jan 2021 14:54:53 +0000 (01:54 +1100)
committerWill Budicm <redacted>
Sat, 2 Jan 2021 14:54:53 +0000 (01:54 +1100)
htdocs/cgi-bin/wsrc/main.js

index 8fa1ae54fea617452c7b696110f39630dd2ff022..aa7fb075539d70dc275a1f9102bcfee01402c60e 100644 (file)
@@ -474,19 +474,18 @@ function decodeToHTMLText(txt) {
     return txt;
 }
 
-var BOLD_MATCH = /(?<o>^\<b\>)(?<title>.+)(?<c>\<\/b\>)\s+(?<text>.*)/gi;
+const REGX_BTM = /(?<o>^\<b\>)(?<title>.+)(?<c>\<\/b\>)/gi;
+const REGX_BTM_SUBST = `*$2*`;
+
 function decodeToText(txt) {
     //bug 7 fix
     txt = txt.replace(/<hr>.*RTF<\/button>/gm, "");
     txt = txt.replace(/<br\s*[\/]?>/gi, "\n");
     //If first line bolded
     
-    let res = txt.matchAll(BOLD_MATCH);
+    let res = txt.matchAll(REGX_BTM);
     if(res){
-        for(let r of res) { //WB: In a loop? JS can be weird, nested iter...
-            let {o, title, close, text} = r.groups;
-            txt = "*" + title + "*\n" + text;
-        }//
+       txt = txt.replace(REGX_BTM, REGX_BTM_SUBST);        
     }
     return txt;
 }