codeblock

command
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

CodeBlock Example

This example shows framed code rendering with Glamour and width-aware wrapping for long snippets.

CodeBlock example

Run

go run ./examples/codeblock --format human --style always
COLUMNS=72 go run ./examples/codeblock --format human --style always --content long --max-width 48 --wrap-mode truncate
COLUMNS=72 go run ./examples/codeblock --format human --style always --content long --max-width 48 --wrap-mode never

Real Library Shape

_ = printer.CodeBlock(laslig.CodeBlock{
	Title:    "Go snippet",
	Language: "go",
	Body:     "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"hello from laslig\")\n}",
	Footer:   "Use CodeBlock when code should stay visibly distinct from prose.",
	MaxWidth: 48,
	WrapMode: laslig.TableWrapTruncate,
})

The code renderer now receives the frame-aware width budget before Glamour renders, so the right border closes cleanly even on narrow terminals.

Code blocks reuse the same TableWrapMode enum as tables, panels, and log blocks. truncate and never currently render the same way on purpose; both keep one logical line per rendered segment and compact by truncating when needed.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL