feat(tui): render entity body as markdown via glamour
Detail pane now pipes entity body through charmbracelet/glamour for styled markdown output — headers, bold, code blocks, lists. Uses hardcoded dark style to avoid terminal query freeze in alt screen.
This commit is contained in:
+15
-1
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/glamour"
|
||||
|
||||
"github.com/lerko/nib/internal/db"
|
||||
"github.com/lerko/nib/internal/display"
|
||||
@@ -98,7 +99,20 @@ func (d detailModel) previewView(width int) string {
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
b.WriteString(detailBodyStyle.Render(e.Body))
|
||||
bodyWidth := width - 4
|
||||
if bodyWidth < 20 {
|
||||
bodyWidth = 20
|
||||
}
|
||||
r, _ := glamour.NewTermRenderer(
|
||||
glamour.WithStylePath("dark"),
|
||||
glamour.WithWordWrap(bodyWidth),
|
||||
)
|
||||
rendered, err := r.Render(e.Body)
|
||||
if err != nil {
|
||||
rendered = e.Body
|
||||
}
|
||||
rendered = strings.TrimRight(rendered, "\n")
|
||||
b.WriteString(detailBodyStyle.Render(rendered))
|
||||
b.WriteString("\n")
|
||||
|
||||
if e.CardType != nil {
|
||||
|
||||
Reference in New Issue
Block a user