@duanz/pi-d-live 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +8 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -762,6 +762,8 @@ function rewrite(s: Sess, sid: string, text: string) {
|
|
|
762
762
|
.split("\n")
|
|
763
763
|
.map((line: string) =>
|
|
764
764
|
line
|
|
765
|
+
// 模型偶尔在句首带个英文词(thinking / done 之类),去掉再入栏
|
|
766
|
+
.replace(/^[A-Za-z][A-Za-z\s]{1,12}(?=[\u4e00-\u9fa5])/, "")
|
|
765
767
|
.replace(/^[-•*\d.、)\s]+/, "")
|
|
766
768
|
.replace(/^["「『]|["」』]$/g, "")
|
|
767
769
|
.trim(),
|
|
@@ -780,7 +782,12 @@ function rewrite(s: Sess, sid: string, text: string) {
|
|
|
780
782
|
if (lines.length) {
|
|
781
783
|
// 一条播报只放一句能塞进一行的:太长的按标点切成两句,免得手机上前端被迫缩字换行
|
|
782
784
|
const capped: string[] = [];
|
|
783
|
-
for (const line of lines)
|
|
785
|
+
for (const line of lines)
|
|
786
|
+
for (const piece of splitLong(line)) {
|
|
787
|
+
// 切句切出来的碎渣(比如单独一个 emoji 加句号)并回上一句,别让它自己占一行
|
|
788
|
+
if (piece.length < 6 && capped.length) capped[capped.length - 1] += piece;
|
|
789
|
+
else capped.push(piece);
|
|
790
|
+
}
|
|
784
791
|
emit({ kind: "lines", sid, lines: capped });
|
|
785
792
|
s.history = s.history.concat(capped).slice(-8);
|
|
786
793
|
}
|