fix: prevent sparse spacing in hyphenated words (#1102)

This commit is contained in:
Tom
2025-07-19 21:28:40 +07:00
committed by GitHub
parent 4bbbbac5f6
commit 2b44dbdbf1
4 changed files with 70 additions and 7 deletions

View File

@@ -83,11 +83,17 @@ func Extension(path string) string {
}
func ToMarkdown(content string, width int, backgroundColor compat.AdaptiveColor) string {
r := styles.GetMarkdownRenderer(width-6, backgroundColor)
renderWidth := width - GetMarkdownContainerFrame()
r := styles.GetMarkdownRenderer(renderWidth, backgroundColor)
content = strings.ReplaceAll(content, RootPath+"/", "")
rendered, _ := r.Render(content)
lines := strings.Split(rendered, "\n")
// Apply hyphen preservation during markdown rendering
rendered := ProcessTextWithHyphens(content, func(t string) string {
result, _ := r.Render(t)
return result
})
lines := strings.Split(rendered, "\n")
// Clean up empty lines at start/end
if len(lines) > 0 {
firstLine := lines[0]
cleaned := ansi.Strip(firstLine)