rotund
This commit is contained in:
+8
-4
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user