From 2edfeb85cbba228913b5daaeff79c692bb2e7a3c Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Sun, 3 Jan 2021 01:54:53 +1100 Subject: [PATCH] Bolded wasn't matching rest of text. --- htdocs/cgi-bin/wsrc/main.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index 8fa1ae5..aa7fb07 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -474,19 +474,18 @@ function decodeToHTMLText(txt) { return txt; } -var BOLD_MATCH = /(?^\)(?.+)(?<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; } -- 2.34.1