Jump to an example
Choose an example...
Editor title Extracted file name Terminal detection Terminal title Minimal dots No frame
Line numbers Custom start Word wrap No preserve indent Hanging indent
Line markers Labeled range No line numbers Numbered labels Focus lines Inline markers Single quotes Combined markers
Basic links Links + markers
Threshold Per-block threshold Range Multiple ranges Gap indicators Collapsible start Collapsible end Collapsible auto
Mermaid Regex markers Regex capture Hybrid diff Code group Tab sync
SGR basics Git diff Truecolor + styles 256-color palette
Per-block override Dual override Theme customizer Theme adjustments Scoped CSS Theme toggle
French locale File icons Lang icon only Lang icon + text
Basic output Editor output Collapsed Custom label
TODO badges Figure caption
Search examples
Category
All categories
Frames Layout Markers and Focus Links Collapsible Sections Formats and Groups ANSI Terminal Output Themes and Customization Localization and Assets Output Panel Post-Render Callbacks
Clear
55 examples
No examples found
Try a different search term or category.
Frames
Editor, terminal, and unframed presentation styles.
Editor Frame (explicit title)
Copy link
Adds familiar editor chrome and an explicit file name above the highlighted code.
fmt . Printf ( "Hello, %s!\n" , name )
How to build this
Meta Go
Copy Meta
go title="main.go" showLineNumbers
Copy Go
html, err := engine.Render(code, kazari.Options{
Lang: "go",
Title: "main.go",
LineNumbers: boolPtr(true),
})
Terminal Frame (auto-detected from language)
Copy link
Automatically presents shell languages in a terminal-style frame instead of an editor frame.
How to build this
Meta Go
Copy Go
html, err := engine.Render(code, kazari.Options{Lang: "bash"})
Terminal Frame (with title)
Copy link
Adds a descriptive session or command label to the terminal title bar.
Get-ChildItem -Path ./ dist -Recurse | Measure-Object -Property Length -Sum
How to build this
Meta Go
Copy Meta
powershell title="PowerShell terminal example"
Copy Go
html, err := engine.Render(code, kazari.Options{
Lang: "powershell",
Title: "PowerShell terminal example",
})
Terminal Frame (minimal dots)
Copy link
Uses a compact engine-level dot style for a quieter terminal title bar.
How to build this
Go
Copy Go
engine := kazari.New(
kazari.WithHighlighter(highlighter),
kazari.WithTerminalDotStyle(kazari.DotsMinimal),
)
html, err := engine.Render(code, kazari.Options{Lang: "bash", Title: "Minimal dots"})
Removes the surrounding window chrome while preserving syntax highlighting and code structure.
fmt . Printf ( "Hello, %s!\n" , name )
How to build this
Meta Go
Copy Meta
go frame="none"
Copy Go
frame := kazari.FrameNone
html, err := engine.Render(code, kazari.Options{Lang: "go", Frame: &frame})
Layout
Line numbering and wrapping behavior for different code shapes.
Adds a numbered gutter so readers can reference specific lines precisely.
fmt . Println ( "Usage: greet <name>" )
name := strings . Join ( args , " " )
fmt . Printf ( "Hello, %s!\n" , name )
Show more
How to build this
Meta Go
Copy Meta
go title="main.go" showLineNumbers
Copy Go
enabled := true
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "main.go", LineNumbers: &enabled,
})
Line Numbers (custom start)
Copy link
Continues numbering from the source file's original location when showing an excerpt.
result := evaluate ( strings . Join ( args , " " ))
fmt . Printf ( "= %v\n" , result )
How to build this
Meta Go
Copy Meta
go title="calc.go (lines 22-24)" showLineNumbers startLineNumber=22
Copy Go
enabled, start := true, 22
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "calc.go (lines 22-24)",
LineNumbers: &enabled, StartLineNumber: &start,
})
Word Wrap (long lines wrap, indent preserved)
Copy link
Wraps long lines within the block while preserving indentation for readable continuations.
func configure ( opts * Options ) {
opts . Logger = log . New ( os . Stdout , "[kazari] a deliberately long prefix string that forces this line to wrap inside the demo container" , log . LstdFlags | log . Lshortfile | log . Lmicroseconds )
opts . Description = "Word wrap keeps long lines visible without horizontal scrolling, and preserved indentation keeps wrapped continuations aligned with the code structure."
How to build this
Meta Go
Copy Meta
go title="wrap.go" showLineNumbers wrap
Copy Go
enabled, wrap := true, true
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "wrap.go", LineNumbers: &enabled, Wrap: &wrap,
})
Word Wrap (preserveIndent=false)
Copy link
Wrapped continuations start at the left edge instead of aligning with the original indentation.
func configure ( opts * Options ) {
opts . Logger = log . New ( os . Stdout , "[kazari] a deliberately long prefix string that forces this line to wrap inside the demo container" , log . LstdFlags | log . Lshortfile | log . Lmicroseconds )
opts . Description = "Word wrap keeps long lines visible without horizontal scrolling, and preserved indentation keeps wrapped continuations aligned with the code structure."
How to build this
Meta Go
Copy Meta
go title="no-preserve.go" showLineNumbers wrap preserveIndent=false
Copy Go
enabled, wrap, noPreserve := true, true, false
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "no-preserve.go",
LineNumbers: &enabled, Wrap: &wrap, PreserveIndent: &noPreserve,
})
Word Wrap (hangingIndent=4)
Copy link
Adds a fixed hanging indent to wrapped continuations so new logical lines are easy to spot.
func configure ( opts * Options ) {
opts . Logger = log . New ( os . Stdout , "[kazari] a deliberately long prefix string that forces this line to wrap inside the demo container" , log . LstdFlags | log . Lshortfile | log . Lmicroseconds )
opts . Description = "Word wrap keeps long lines visible without horizontal scrolling, and preserved indentation keeps wrapped continuations aligned with the code structure."
How to build this
Meta Go
Copy Meta
go title="hanging.go" showLineNumbers wrap preserveIndent=false hangingIndent=4
Copy Go
enabled, wrap, noPreserve, hanging := true, true, false, 4
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "hanging.go",
LineNumbers: &enabled, Wrap: &wrap,
PreserveIndent: &noPreserve, HangingIndent: &hanging,
})
Markers and Focus
Call attention to lines, ranges, and inline text without losing syntax highlighting.
Line Markers (mark, ins, del)
Copy link
Distinguishes highlighted, inserted, and deleted lines with clear full-line treatments.
func oldGreet ( name string ) {
func newGreet ( name string ) {
fmt . Printf ( "Hello, %s! Welcome!\n" , name )
How to build this
Meta Go
Copy Meta
go title="diff.go" showLineNumbers {3} del={5-7} ins={9-11}
Copy Go
html, err := engine.RenderWithMeta(code, `go title="diff.go" showLineNumbers {3} del={5-7} ins={9-11}`)
Attaches explanatory labels to marked line ranges so each change can carry context.
class UserController extends Controller
private UserRepository $users ;
private LoggerInterface $logger ;
public function __construct (
public function show ( int $id ) : Response
$user = $this -> users -> find ( $id );
throw new NotFoundHttpException ();
return $this -> json ( $user );
How to build this
Meta Go
Copy Meta
php title="UserController.php" showLineNumbers {"1. Inject dependencies via constructor:":5-12} del={"2. Remove inline lookup logic:":16-20} ins={"3. Return a JSON response:":21-22}
Copy Go
html, err := engine.RenderWithMeta(code, meta)
Labeled Range (no line numbers)
Copy link
Labeled ranges without line numbers place the badge flush at the left edge of the block.
class UserController extends Controller
private UserRepository $users ;
private LoggerInterface $logger ;
public function __construct (
public function show ( int $id ) : Response
$user = $this -> users -> find ( $id );
throw new NotFoundHttpException ();
return $this -> json ( $user );
How to build this
Meta Go
Copy Meta
php title="UserController.php" {"1. Inject dependencies via constructor:":5-12} del={"2. Remove inline lookup logic:":16-20} ins={"3. Return a JSON response:":21-22}
Copy Go
html, err := engine.RenderWithMeta(code, meta)
Labeled Range (numbered)
Copy link
Short numeric labels act as compact reference badges on the first line of each range.
class UserController extends Controller
private UserRepository $users ;
private LoggerInterface $logger ;
public function __construct (
public function show ( int $id ) : Response
$user = $this -> users -> find ( $id );
throw new NotFoundHttpException ();
return $this -> json ( $user );
How to build this
Meta Go
Copy Meta
php title="UserController.php" {"1":6-9} del={"2":17-19} ins={"3":21-22}
Copy Go
html, err := engine.RenderWithMeta(code, meta)
Keeps selected lines prominent while dimming the surrounding code for emphasis.
func process ( items [] string ) error {
for _ , item := range items {
if err := validate ( item ); err != nil {
return fmt . Errorf ( "invalid: %w" , err )
How to build this
Meta Go
Copy Meta
go title="process.go" showLineNumbers focus={3-5}
Copy Go
html, err := engine.RenderWithMeta(code, `go title="process.go" showLineNumbers focus={3-5}`)
Highlights matching text inside a line without losing the underlying syntax colors.
interface CacheEntry < T > {
function getOrSet < T >( cache : Map < string , CacheEntry < T >>, key : string , factory : () => T ) : T {
const entry = cache . get ( key );
if ( entry && entry . expiresAt > Date . now ()) {
cache . set ( key , { key , value , expiresAt : Date.now () + 3600 _000 });
How to build this
Meta Go
Copy Meta
typescript title="cache.ts" showLineNumbers "CacheEntry" ins="factory"
Copy Go
html, err := engine.RenderWithMeta(code, `typescript title="cache.ts" showLineNumbers "CacheEntry" ins="factory"`)
Inline Markers (single quotes)
Copy link
Uses single-quoted marker expressions when the highlighted text or meta string needs simpler escaping.
var query = context . Users
. OrderBy ( u => u . CreatedAt )
. Select( u => new UserDto ( u . Name , u . Email ));
How to build this
Meta Go
Copy Meta
csharp title="UserQuery.cs" showLineNumbers 'context' ins='OrderBy' del='Select'
Copy Go
html, err := engine.RenderWithMeta(code, meta)
Combined (markers + inline + focus)
Copy link
Layers line markers, inline matches, and focused ranges in the same code block.
users , err := db . Query ( "SELECT * FROM users" )
for _ , u := range users {
How to build this
Meta Go
Copy Meta
go title="combined.go" showLineNumbers {4-5} ins={10-12} del={6-8} "db" focus={4-5,10-12}
Copy Go
html, err := engine.RenderWithMeta(code, meta)
Links
Clickable hyperlinks inside code blocks using @[text](url) syntax.
Wraps identifiers in clickable links using @[text](url) syntax. The link text keeps its syntax color and gains a dotted underline.
How to build this
Source Go
Copy Source
import (
@[fmt](https://pkg.go.dev/fmt)
@[net/http](https://pkg.go.dev/net/http)
)
func main() {
@[http.HandleFunc](https://pkg.go.dev/net/http#HandleFunc)("/", handler)
@[http.ListenAndServe](https://pkg.go.dev/net/http#ListenAndServe)(":8080", nil)
}
Copy Go
engine := kazari.New(kazari.WithLinks(true))
html, err := engine.Render(code, kazari.Options{Lang: "go", Title: "main.go"})
Links + Inline Markers
Copy link
Links compose with inline markers on the same line. Marked text inside a link gets both the marker element and the anchor wrapper.
document . getElementById ( "root" )
How to build this
Source Meta
Copy Source
const root = @[createRoot](https://react.dev/reference/react-dom/client/createRoot)(
document.getElementById("root")
)
root.render(<@[StrictMode](https://react.dev/reference/react/StrictMode)><App /></@[StrictMode](https://react.dev/reference/react/StrictMode)>)
Copy Meta
jsx title="index.tsx" "createRoot" ins="StrictMode"
Collapsible Sections
Threshold and range-based strategies for keeping long examples compact.
Threshold-based (auto-collapses long blocks)
Copy link
Automatically collapses long blocks when they exceed the engine's configured line threshold.
func NewServer ( addr string ) * Server {
handler : http . DefaultServeMux ,
logger : log . New ( os . Stdout , "[server] " , log . LstdFlags ),
func ( s * Server ) Start () error {
s . logger . Printf ( "Starting server on %s" , s . addr )
return http . ListenAndServe ( s . addr , s . handler )
Show more
How to build this
Go
Copy Go
engine := kazari.New(kazari.WithCollapsible(kazari.CollapsibleConfig{
LineThreshold: 12, PreviewLines: 6, DefaultCollapsed: true,
}))
html, err := engine.Render(code, kazari.Options{Lang: "go", Title: "server.go"})
Per-block threshold override
Copy link
Overrides the engine threshold for a single block via collapseThreshold=N in the meta string.
func NewServer ( addr string ) * Server {
handler : http . DefaultServeMux ,
logger : log . New ( os . Stdout , "[server] " , log . LstdFlags ),
func ( s * Server ) Start () error {
s . logger . Printf ( "Starting server on %s" , s . addr )
return http . ListenAndServe ( s . addr , s . handler )
Show more
How to build this
Meta Go
Copy Meta
go title="server.go" collapseThreshold=20
Copy Go
threshold := 20
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "server.go",
Collapse: &kazari.CollapseOptions{Threshold: &threshold},
})
Range-based (imports collapsed)
Copy link
Hides a selected line range behind an expandable summary to keep the main logic visible.
fmt . Println ( "Usage: calc <expr>" )
result := evaluate ( strings . Join ( args , " " ))
fmt . Printf ( "= %v\n" , result )
func evaluate ( expr string ) float64 {
val , _ := strconv . ParseFloat ( expr , 64 )
Show more
How to build this
Meta Go
Copy Meta
go title="calc.go" showLineNumbers collapse={3-8}
Copy Go
html, err := engine.RenderWithMeta(code, `go title="calc.go" showLineNumbers collapse={3-8}`)
Multiple ranges
Copy link
Collapses multiple independent ranges so distant supporting sections stay compact.
func handleGet ( w http . ResponseWriter , r * http . Request ) {
data := fetchData ( r . URL . Query ())
json . NewEncoder ( w ). Encode ( Response { Status : 200 , Message : "OK" , Data : data })
func handlePost ( w http . ResponseWriter , r * http . Request ) {
var body map [ string ] interface {}
json . NewDecoder ( r . Body ). Decode ( & body )
result := processData ( body )
json . NewEncoder ( w ). Encode ( Response { Status : 201 , Message : "Created" , Data : result })
Show more
How to build this
Meta Go
Copy Meta
go title="api.go" showLineNumbers collapse={3-7,9-13}
Copy Go
html, err := engine.RenderWithMeta(code, meta)
Threshold + markers (gap indicators)
Copy link
Shows omitted regions as gap indicators while preserving important marked lines around them.
log . SetFlags ( log . LstdFlags | log . Lshortfile )
mux := http . NewServeMux ()
mux . HandleFunc ( "/health" , healthHandler )
mux . HandleFunc ( "/api/data" , dataHandler )
log . Fatal ( http . ListenAndServe ( ":8080" , mux ))
func healthHandler ( w http . ResponseWriter , r * http . Request ) {
w . WriteHeader ( http . StatusOK )
func dataHandler ( w http . ResponseWriter , r * http . Request ) {
data := map [ string ] interface {}{ "status" : "success" , "count" : 42 }
json . NewEncoder ( w ). Encode ( data )
Show more
How to build this
Go
Copy Go
enabled := true
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "server.go", LineNumbers: &enabled,
LineMarkers: []kazari.LineMarker{{
Type: kazari.MarkerIns,
Lines: []kazari.Range{{Start: 10, End: 11}},
}},
})
collapsible-start (re-collapsible, summary above)
Copy link
Places the expansion summary above a range that can be collapsed again after opening.
fmt . Println ( "Usage: calc <expr>" )
result := evaluate ( strings . Join ( args , " " ))
fmt . Printf ( "= %v\n" , result )
func evaluate ( expr string ) float64 {
val , _ := strconv . ParseFloat ( expr , 64 )
Show more
How to build this
Meta Go
Copy Meta
go title="calc.go" showLineNumbers collapse={3-8} collapseStyle="collapsible-start"
Copy Go
enabled := true
style := kazari.CollapseCollapsibleStart
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "calc.go", LineNumbers: &enabled,
Collapse: &kazari.CollapseOptions{
Ranges: []kazari.Range{{Start: 3, End: 8}},
Style: &style,
},
})
collapsible-end (re-collapsible, summary below)
Copy link
Places the expansion summary below a range that can be collapsed again after opening.
fmt . Println ( "Usage: calc <expr>" )
result := evaluate ( strings . Join ( args , " " ))
fmt . Printf ( "= %v\n" , result )
func evaluate ( expr string ) float64 {
val , _ := strconv . ParseFloat ( expr , 64 )
Show more
How to build this
Meta Go
Copy Meta
go title="calc.go" showLineNumbers collapse={3-8} collapseStyle="collapsible-end"
Copy Go
enabled := true
style := kazari.CollapseCollapsibleEnd
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "calc.go", LineNumbers: &enabled,
Collapse: &kazari.CollapseOptions{
Ranges: []kazari.Range{{Start: 3, End: 8}},
Style: &style,
},
})
collapsible-auto (auto start/end based on position)
Copy link
Chooses the summary position from the collapsed range's location within the code block.
fmt . Println ( "Usage: calc <expr>" )
result := evaluate ( strings . Join ( args , " " ))
fmt . Printf ( "= %v\n" , result )
func evaluate ( expr string ) float64 {
val , _ := strconv . ParseFloat ( expr , 64 )
Show more
How to build this
Meta Go
Copy Meta
go title="calc.go" showLineNumbers collapse={3-8,20-24} collapseStyle="collapsible-auto"
Copy Go
enabled := true
style := kazari.CollapseCollapsibleAuto
html, err := engine.Render(code, kazari.Options{
Lang: "go", Title: "calc.go", LineNumbers: &enabled,
Collapse: &kazari.CollapseOptions{
Ranges: []kazari.Range{{Start: 3, End: 8}, {Start: 20, End: 24}},
Style: &style,
},
})
ANSI Terminal Output
Renders ANSI SGR escape sequences into styled HTML with full color and text decoration support.
ANSI Escape Sequences (parsed SGR codes)
Copy link
Converts ANSI SGR escape sequences into styled terminal colors and text treatments.
INFO Server started on :8080
WARN Cache miss for key "user:42"
ERROR Connection refused: db.example.com:5432
2024-01-15 10:30:45 DEBUG Retrying in 3s ...
How to build this
Meta Go
Copy Meta
ansi title="server.log" showLineNumbers
Copy Go
html, err := engine.RenderWithMeta(code, `ansi title="server.log" showLineNumbers`)
ANSI Git Diff (16-color foreground + background)
Copy link
Renders git diff output with bold headers, cyan hunk markers, and red/green background strips for deleted and inserted lines.
diff --git a/api/handler.go b/api/handler.go
index 4e9d2a1..7c3f8b2 100644
@@ -12,7 +12,9 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request) {
- log.Printf("request: %s %s", r.Method, r.URL.Path)
+ spanCtx, span := tracer.Start(ctx, "ServeHTTP")
+ log.Printf("trace: %s %s", r.Method, r.URL.Path)
handler(w, r.WithContext(ctx))
How to build this
Meta Go
Copy Meta
ansi title="git diff" showLineNumbers
Copy Go
html, err := engine.RenderWithMeta(code, `ansi title="git diff" showLineNumbers`)
ANSI Truecolor + Styles (24-bit RGB, italic, strikethrough, underline)
Copy link
Demonstrates 24-bit truecolor foregrounds alongside italic, bold, strikethrough, and underline text styles.
deprecated: use tokio::task::spawn_local instead
ERROR [E0308] mismatched types
For more information: rustc --explain E0308
How to build this
Meta Go
Copy Meta
ansi title="cargo build" showLineNumbers
Copy Go
html, err := engine.RenderWithMeta(code, `ansi title="cargo build" showLineNumbers`)
ANSI 256-Color Palette (cube, grayscale, background)
Copy link
Exercises all three 256-color zones: the standard palette, the 6x6x6 color cube, and the grayscale ramp.
drwxr-xr-x 2 user user 4096 src/
drwxr-xr-x 2 user user 4096 tests/
-rwxr-xr-x 1 user user 8192 build.sh
-rw-r--r-- 1 user user 512 ERROR.log
-rw-r--r-- 1 user user 2048 config.yaml
-rw-r--r-- 1 user user 64 .gitignore
-rw-r--r-- 1 user user 1024 README.md
How to build this
Meta Go
Copy Meta
ansi title="ls --color" showLineNumbers
Copy Go
html, err := engine.RenderWithMeta(code, `ansi title="ls --color" showLineNumbers`)
Themes and Customization
Per-block themes, generated adjustments, and scoped CSS output.
Per-Block Theme Override (default vs dracula)
Copy link
Selects an alternate theme for one block without changing the rest of the page.
fmt . Println ( "Same code, different theme" )
fmt . Println ( "Same code, different theme" )
How to build this
Meta Go
Copy Meta
go title="default theme" showLineNumbers
go title="theme=dracula" showLineNumbers theme="dracula"
Copy Go
defaultHTML, err := engine.RenderWithMeta(code, `go title="default theme" showLineNumbers`)
draculaHTML, err := engine.RenderWithMeta(code, `go title="theme=dracula" showLineNumbers theme="dracula"`)
Per-Block Theme Override (dual: dracula + github-light)
Copy link
Gives one block its own light and dark themes, switched by the page's dark mode toggle. Inverted here on purpose: dracula in light mode, github-light in dark mode.
fmt . Println ( "Same code, different theme" )
How to build this
Meta Go
Copy Meta
go title="theme=dracula,github-light" showLineNumbers theme="dracula,github-light"
Copy Go
html, err := engine.RenderWithMeta(code, `go showLineNumbers theme="dracula,github-light"`)
Theme Customizer (dark BG changed to #1a1b26)
Copy link
Adjusts resolved theme colors through a callback before Kazari generates the CSS variables.
fmt . Println ( "Custom dark BG: #1a1b26" )
How to build this
Go
Copy Go
engine := kazari.New(
kazari.WithThemeCSSRoot(".kazari-customizer"),
kazari.WithThemeCustomizer(func(name string, colors kazari.ThemeInfo) kazari.ThemeInfo {
if name == "github-dark" { colors.BG = "#1a1b26" }
return colors
}),
)
Theme Adjustments (OKLCH teal tint)
Copy link
Applies an OKLCH tint to generated theme colors while preserving their visual relationships.
fmt . Println ( "Backgrounds tinted toward teal in OKLCH space" )
How to build this
Go
Copy Go
hue, chroma := 195.0, 0.04
engine := kazari.New(
kazari.WithThemeCSSRoot(".kazari-tinted"),
kazari.WithThemeAdjustments(kazari.ThemeAdjustments{
Hue: &hue, Chroma: &chroma,
}),
)
Scoped CSS Root (.kazari-scoped)
Copy link
Emits theme variables beneath a custom selector so Kazari styles stay inside a chosen container.
fmt . Println ( "CSS vars scoped to .kazari-scoped" )
How to build this
Go
Copy Go
engine := kazari.New(kazari.WithThemeCSSRoot(".kazari-scoped"))
css := engine.CSS()
Per-Block Theme Toggle
Copy link
Adds a per-block toggle button that lets readers switch an individual code block between light and dark themes independently of the page.
fmt . Println ( "Toggle this block's theme!" )
const greeting = "Each block toggles independently" ;
How to build this
Go
Copy Go
engine := kazari.New(
kazari.WithHighlighter(highlighter),
kazari.WithThemeToggle(true),
)
html, err := engine.Render(code, kazari.Options{Lang: "go", Title: "theme-toggle.go"})
Localization and Assets
Localized controls and consumer-provided file icon resolution.
Locale: French (WithLocale("fr-FR"))
Copy link
Localizes built-in copy and fullscreen controls through the engine's locale setting.
fmt . Println ( "Bonjour le monde !" )
How to build this
Go
Copy Go
engine := kazari.New(kazari.WithLocale("fr-FR"))
html, err := engine.Render(code, kazari.Options{Lang: "go", Title: "locale-fr.go"})
File Icons (custom resolver)
Copy link
Resolves a custom icon from each title's file extension and places it in the frame toolbar.
How to build this
Go
Copy Go
engine := kazari.New(kazari.WithFileIconResolver(func(ext string) string {
icons := map[string]string{"go": "🔵", "py": "🐍", "js": "🟡", "rs": "🦀"}
return fmt.Sprintf("<span class=\"kz-file-icon\">%s</span>", icons[ext])
}))
Language Icons: Icon Only (LangIconOnly)
Copy link
Replaces the language text badge with a CSS icon slot that the consumer styles via [data-lang] selectors. Color SVG icons are available from Devicon .
How to build this
Go
Copy Go
engine := kazari.New(kazari.WithLanguageIconMode(kazari.LangIconOnly))
Language Icons: Icon + Text (LangIconAndText)
Copy link
Shows a language icon before the text label, giving both a visual cue and a readable name. Color SVG icons are available from Devicon .
How to build this
Go
Copy Go
engine := kazari.New(kazari.WithLanguageIconMode(kazari.LangIconAndText))
Output Panel
Separate command output from highlighted source code.
Basic Output Panel
Copy link
Separates terminal commands from their output in a linked panel below the highlighted code.
/usr/home/boba-tan
total 24
drwxr-xr-x 3 boba boba 4096 Jun 28 14:30 .
How to build this
Meta Go
Copy Meta
bash withOutput
Copy Go
html, err := engine.Render(code, kazari.Options{
Lang: "bash",
WithOutput: boolPtr(true),
})
Editor Frame Output
Copy link
Attaches program output beneath an editor-framed source block with an explicit file title.
fmt . Println ( "Hello, Kazari!" )
fmt . Println ( "Output panels are here." )
Hello, Kazari!
Output panels are here.
How to build this
Meta Go
Copy Go
html, err := engine.Render(code, kazari.Options{
Lang: "go",
WithOutput: boolPtr(true),
})
Collapsed Output
Copy link
Starts the output panel hidden so readers can focus on the code and reveal output on demand.
How to build this
Meta Go
Copy Meta
bash withOutput outputCollapsed
Copy Go
html, err := engine.Render(code, kazari.Options{
Lang: "bash",
WithOutput: boolPtr(true),
OutputCollapsed: boolPtr(true),
})
Replaces the default toggle label with a descriptive name that fits the example context.
Server listening on port 3000
How to build this
Meta Go
Copy Meta
bash withOutput outputLabel="Run result"
Copy Go
html, err := engine.Render(code, kazari.Options{
Lang: "bash",
WithOutput: boolPtr(true),
OutputLabel: "Run result",
})
Post-Render Callbacks
Extend rendered output with WithPostRender callbacks.
TODO/FIXME Badges
Copy link
Injects warning badges next to TODO and FIXME comments using a WithPostRender callback.
// TODO add TLS configuration
http . HandleFunc ( "/" , handler )
// FIXME this ignores the returned error
http . ListenAndServe ( ":8080" , nil )
How to build this
Go
Copy Go
todoRe := regexp.MustCompile(`(>[^<]*?)(TODO:)`)
fixmeRe := regexp.MustCompile(`(>[^<]*?)(FIXME:)`)
todoCallback := func(html string, info kazari.BlockInfo) string {
html = todoRe.ReplaceAllString(html,
`${1}<span class="kz-todo-badge">TODO</span> `)
html = fixmeRe.ReplaceAllString(html,
`${1}<span class="kz-fixme-badge">FIXME</span> `)
return html
}
engine := kazari.New(
kazari.WithHighlighter(hl),
kazari.WithPostRender(todoCallback),
)
Wraps the code block in a figure element with a caption derived from the block title.
How to build this
Go
Copy Go
figcaptionCallback := func(html string, info kazari.BlockInfo) string {
if info.Title == "" {
return html
}
return fmt.Sprintf(
"<figure>%s<figcaption>%s</figcaption></figure>",
html, info.Title,
)
}
engine := kazari.New(
kazari.WithHighlighter(hl),
kazari.WithPostRender(figcaptionCallback),
)