package main import ( "bytes" "context" "sync/atomic" ) // imgCounter assigns sequential [fig.N] numbers in render order so each // rendered terminal image gets a unique caption number. var imgCounter uint64 // TerminalImageBlock wraps the built-in image in a +----+ ASCII frame with // a [fig.N caption] line beneath it. // // Content shape (same as built-in image): {src, alt, caption, width, height}. func TerminalImageBlock(ctx context.Context, content map[string]any) string { src := getString(content, "src") alt := getString(content, "alt") caption := getString(content, "caption") if alt == "" { alt = caption } n := atomic.AddUint64(&imgCounter, 1) var buf bytes.Buffer _ = terminalImageComponent(src, alt, caption, n).Render(ctx, &buf) return buf.String() }