mirror of
https://github.com/sst/opencode.git
synced 2025-08-02 21:02:15 +00:00
fix: bullet display (#1148)
This commit is contained in:
parent
97d9c851e6
commit
9c5d9be33a
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/lipgloss/v2"
|
||||
|
@ -9,8 +10,12 @@ import (
|
|||
// PreventHyphenBreaks replaces regular hyphens with non-breaking hyphens to prevent
|
||||
// sparse word breaks in hyphenated terms like "claude-code-action".
|
||||
// This improves readability by keeping hyphenated words together.
|
||||
// Only preserves hyphens within words, not markdown syntax like bullet points.
|
||||
func PreventHyphenBreaks(text string) string {
|
||||
return strings.ReplaceAll(text, "-", "\u2011")
|
||||
// Use regex to match hyphens that are between word characters
|
||||
// This preserves hyphens in words like "claude-code-action" but not in "- [ ]"
|
||||
re := regexp.MustCompile(`(\w)-(\w)`)
|
||||
return re.ReplaceAllString(text, "$1\u2011$2")
|
||||
}
|
||||
|
||||
// RestoreHyphens converts non-breaking hyphens back to regular hyphens.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue