dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 5536c633de8c06224305c70174a6552007ca22d8
parent ce99188459f2e51cfb738f57be1a30be98c28302
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 28 Jun 2023 11:16:30 -0700

support escaped new line char in manual multiline mode

Diffstat:
Mpkg/database/utils/processMessage.go | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/pkg/database/utils/processMessage.go b/pkg/database/utils/processMessage.go @@ -235,11 +235,18 @@ func GetQuoteTxt(db *database.DkfDB, roomKey string, quoted database.ChatMessage return `“[` + quoted.CreatedAt.Format("15:04:05") + "]" + remaining + `”` } +var manualMultilineRgx = regexp.MustCompile(`(\\)?(\\n)`) + func convertNewLines(html string, canUseMultiline, manualML bool) string { if !canUseMultiline { html = strings.ReplaceAll(html, "\n", "") } else if manualML { - html = strings.ReplaceAll(html, "\\n", "\n") + html = manualMultilineRgx.ReplaceAllStringFunc(html, func(s string) string { + if s == `\\n` { + return "\\n" + } + return "\n" + }) } return html }