This commit is contained in:
2026-08-16 20:07:53 +01:00
parent eebb6906c6
commit 58ae55e061
16 changed files with 369 additions and 171 deletions
+8 -4
View File
@@ -1,6 +1,7 @@
package main
import (
"fmt"
"html"
"regexp"
"strings"
@@ -14,7 +15,7 @@ var (
codeRE = regexp.MustCompile("`([^`]+)`")
)
func XEPToPango(text string) string {
func XEPToPango(text string, correction bool) string {
formatInline := func(s string) string {
s = html.EscapeString(s)
s = boldRE.ReplaceAllString(s, "<b>$1</b>")
@@ -24,13 +25,12 @@ func XEPToPango(text string) string {
return s
}
format := func(s string) string {
lines := strings.Split(s, "\n")
for i, line := range lines {
lines[i] = formatInline(line)
lines[i] = formatInline(line)
}
return strings.Join(lines, "\n")
@@ -56,5 +56,9 @@ func XEPToPango(text string) string {
b.WriteString(format(text[last:]))
return b.String()
str := b.String()
if correction {
str = fmt.Sprintf("%s %s", str, loadedLocale["correction"])
}
return str
}