Code blocks highlighted by Chroma.

55 examples

Frames

Editor, terminal, and unframed presentation styles.

Editor Frame (explicit title)

Adds familiar editor chrome and an explicit file name above the highlighted code.

Gomain.go
package main
import "fmt"
func main() {
name := "Kazari"
fmt.Printf("Hello, %s!\n", name)
}
How to build this
go title="main.go" showLineNumbers

Editor Frame (file name extracted from comment)

Extracts the file name from a leading source comment when no title is provided.

JavaScriptsrc/greet.js
const greet = (name) => {
console.log("Hello, " + name + "!");
return { greeting: name, time: Date.now() };
};
How to build this
javascript

Terminal Frame (auto-detected from language)

Automatically presents shell languages in a terminal-style frame instead of an editor frame.

Terminal window
npm install kazari
go build ./...
echo "Done!"
How to build this
bash

Terminal Frame (with title)

Adds a descriptive session or command label to the terminal title bar.

PowerShell terminal example
Get-ChildItem -Path ./dist -Recurse | Measure-Object -Property Length -Sum
How to build this
powershell title="PowerShell terminal example"

Terminal Frame (minimal dots)

Uses a compact engine-level dot style for a quieter terminal title bar.

Minimal dots
npm install kazari
go build ./...
echo "Done!"
How to build this

Go

engine := kazari.New(
	kazari.WithHighlighter(highlighter),
	kazari.WithTerminalDotStyle(kazari.DotsMinimal),
)
html, err := engine.Render(code, kazari.Options{Lang: "bash", Title: "Minimal dots"})

No Frame

Removes the surrounding window chrome while preserving syntax highlighting and code structure.

package main
import "fmt"
func main() {
name := "world"
fmt.Printf("Hello, %s!\n", name)
for i := 0; i < 3; i++ {
fmt.Println(i)
}
}
How to build this
go frame="none"

Layout

Line numbering and wrapping behavior for different code shapes.

Line Numbers

Adds a numbered gutter so readers can reference specific lines precisely.

Gomain.go
package main
import (
"fmt"
"os"
"strings"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
fmt.Println("Usage: greet <name>")
os.Exit(1)
}
name := strings.Join(args, " ")
fmt.Printf("Hello, %s!\n", name)
}
How to build this
go title="main.go" showLineNumbers

Line Numbers (custom start)

Continues numbering from the source file's original location when showing an excerpt.

Gocalc.go (lines 22-24)
result := evaluate(strings.Join(args, " "))
fmt.Printf("= %v\n", result)
}
How to build this
go title="calc.go (lines 22-24)" showLineNumbers startLineNumber=22

Word Wrap (long lines wrap, indent preserved)

Wraps long lines within the block while preserving indentation for readable continuations.

Gowrap.go
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
go title="wrap.go" showLineNumbers wrap

Word Wrap (preserveIndent=false)

Wrapped continuations start at the left edge instead of aligning with the original indentation.

Gono-preserve.go
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
go title="no-preserve.go" showLineNumbers wrap preserveIndent=false

Word Wrap (hangingIndent=4)

Adds a fixed hanging indent to wrapped continuations so new logical lines are easy to spot.

Gohanging.go
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
go title="hanging.go" showLineNumbers wrap preserveIndent=false hangingIndent=4

Markers and Focus

Call attention to lines, ranges, and inline text without losing syntax highlighting.

Line Markers (mark, ins, del)

Distinguishes highlighted, inserted, and deleted lines with clear full-line treatments.

Godiff.go
package main
import "fmt"
func oldGreet(name string) {
fmt.Println("Hi,", name)
}
func newGreet(name string) {
fmt.Printf("Hello, %s! Welcome!\n", name)
}
func main() {
newGreet("Kazari")
}
How to build this
go title="diff.go" showLineNumbers {3} del={5-7} ins={9-11}

Labeled Range

Attaches explanatory labels to marked line ranges so each change can carry context.

PHPUserController.php
class UserController extends Controller
{
private UserRepository $users;
private LoggerInterface $logger;
public function __construct(
UserRepository $users,
LoggerInterface $logger
) {
$this->users = $users;
$this->logger = $logger;
}
public function show(int $id): Response
{
$user = $this->users->find($id);
if ($user === null) {
throw new NotFoundHttpException();
}
return $this->json($user);
}
}
How to build this
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}

Labeled Range (no line numbers)

Labeled ranges without line numbers place the badge flush at the left edge of the block.

PHPUserController.php
class UserController extends Controller
{
private UserRepository $users;
private LoggerInterface $logger;
public function __construct(
UserRepository $users,
LoggerInterface $logger
) {
$this->users = $users;
$this->logger = $logger;
}
public function show(int $id): Response
{
$user = $this->users->find($id);
if ($user === null) {
throw new NotFoundHttpException();
}
return $this->json($user);
}
}
How to build this
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}

Labeled Range (numbered)

Short numeric labels act as compact reference badges on the first line of each range.

PHPUserController.php
class UserController extends Controller
{
private UserRepository $users;
private LoggerInterface $logger;
public function __construct(
UserRepository $users,
LoggerInterface $logger
) {
$this->users = $users;
$this->logger = $logger;
}
public function show(int $id): Response
{
$user = $this->users->find($id);
if ($user === null) {
throw new NotFoundHttpException();
}
return $this->json($user);
}
}
How to build this
php title="UserController.php" {"1":6-9} del={"2":17-19} ins={"3":21-22}

Focus Lines

Keeps selected lines prominent while dimming the surrounding code for emphasis.

Goprocess.go
func process(items []string) error {
for _, item := range items {
if err := validate(item); err != nil {
return fmt.Errorf("invalid: %w", err)
}
store(item)
}
return nil
}
How to build this
go title="process.go" showLineNumbers focus={3-5}

Inline Markers

Highlights matching text inside a line without losing the underlying syntax colors.

TypeScriptcache.ts
interface CacheEntry<T> {
key: string;
value: T;
expiresAt: number;
}
function getOrSet<T>(cache: Map<string, CacheEntry<T>>, key: string, factory: () => T): T {
const entry = cache.get(key);
if (entry && entry.expiresAt > Date.now()) {
return entry.value;
}
const value = factory();
cache.set(key, { key, value, expiresAt: Date.now() + 3600_000 });
return value;
}
How to build this
typescript title="cache.ts" showLineNumbers "CacheEntry" ins="factory"

Inline Markers (single quotes)

Uses single-quoted marker expressions when the highlighted text or meta string needs simpler escaping.

CsharpUserQuery.cs
var query = context.Users
.Where(u => u.IsActive)
.OrderBy(u => u.CreatedAt)
.Select(u => new UserDto(u.Name, u.Email));
How to build this
csharp title="UserQuery.cs" showLineNumbers 'context' ins='OrderBy' del='Select'

Combined (markers + inline + focus)

Layers line markers, inline matches, and focused ranges in the same code block.

Gocombined.go
func main() {
db := connect()
defer db.Close()
users, err := db.Query("SELECT * FROM users")
if err != nil {
log.Fatal(err)
}
for _, u := range users {
fmt.Println(u.Name)
}
}
How to build this
go title="combined.go" showLineNumbers {4-5} ins={10-12} del={6-8} "db" focus={4-5,10-12}

Collapsible Sections

Threshold and range-based strategies for keeping long examples compact.

Threshold-based (auto-collapses long blocks)

Automatically collapses long blocks when they exceed the engine's configured line threshold.

Goserver.go
package main
import (
"fmt"
"net/http"
"log"
"encoding/json"
"os"
)
type Server struct {
addr string
handler http.Handler
logger *log.Logger
}
func NewServer(addr string) *Server {
return &Server{
addr: addr,
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)
}
How to build this

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

Overrides the engine threshold for a single block via collapseThreshold=N in the meta string.

Goserver.go
package main
import (
"fmt"
"net/http"
"log"
"encoding/json"
"os"
)
type Server struct {
addr string
handler http.Handler
logger *log.Logger
}
func NewServer(addr string) *Server {
return &Server{
addr: addr,
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)
}
How to build this
go title="server.go" collapseThreshold=20

Range-based (imports collapsed)

Hides a selected line range behind an expandable summary to keep the main logic visible.

Gocalc.go
package main
6 collapsed lines
import (
"fmt"
"os"
"strings"
"strconv"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
fmt.Println("Usage: calc <expr>")
os.Exit(1)
}
result := evaluate(strings.Join(args, " "))
fmt.Printf("= %v\n", result)
}
func evaluate(expr string) float64 {
val, _ := strconv.ParseFloat(expr, 64)
return val
}
How to build this
go title="calc.go" showLineNumbers collapse={3-8}

Multiple ranges

Collapses multiple independent ranges so distant supporting sections stay compact.

Goapi.go
package api
5 collapsed lines
import (
"encoding/json"
"net/http"
"log"
)
5 collapsed lines
type Response struct {
Status int
Message string
Data interface{}
}
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})
}
How to build this
go title="api.go" showLineNumbers collapse={3-7,9-13}

Threshold + markers (gap indicators)

Shows omitted regions as gap indicators while preserving important marked lines around them.

Goserver.go
package main
import (
"fmt"
"net/http"
"log"
Lines hidden
"encoding/json"
"os"
"strings"
"strconv"
)
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
func main() {
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)
fmt.Fprint(w, "ok")
}
func dataHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"status": "success", "count": 42}
json.NewEncoder(w).Encode(data)
}
How to build this

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)

Places the expansion summary above a range that can be collapsed again after opening.

Gocalc.go
package main
6 collapsed lines
import (
"fmt"
"os"
"strings"
"strconv"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
fmt.Println("Usage: calc <expr>")
os.Exit(1)
}
result := evaluate(strings.Join(args, " "))
fmt.Printf("= %v\n", result)
}
func evaluate(expr string) float64 {
val, _ := strconv.ParseFloat(expr, 64)
return val
}
How to build this
go title="calc.go" showLineNumbers collapse={3-8} collapseStyle="collapsible-start"

collapsible-end (re-collapsible, summary below)

Places the expansion summary below a range that can be collapsed again after opening.

Gocalc.go
package main
6 collapsed lines
import (
"fmt"
"os"
"strings"
"strconv"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
fmt.Println("Usage: calc <expr>")
os.Exit(1)
}
result := evaluate(strings.Join(args, " "))
fmt.Printf("= %v\n", result)
}
func evaluate(expr string) float64 {
val, _ := strconv.ParseFloat(expr, 64)
return val
}
How to build this
go title="calc.go" showLineNumbers collapse={3-8} collapseStyle="collapsible-end"

collapsible-auto (auto start/end based on position)

Chooses the summary position from the collapsed range's location within the code block.

Gocalc.go
package main
6 collapsed lines
import (
"fmt"
"os"
"strings"
"strconv"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
fmt.Println("Usage: calc <expr>")
os.Exit(1)
}
result := evaluate(strings.Join(args, " "))
fmt.Printf("= %v\n", result)
}
5 collapsed lines
func evaluate(expr string) float64 {
val, _ := strconv.ParseFloat(expr, 64)
return val
}
How to build this
go title="calc.go" showLineNumbers collapse={3-8,20-24} collapseStyle="collapsible-auto"

Formats and Groups

Specialized formats, regex matching, diffs, and tabbed groups.

Mermaid Pass-Through (raw code for Mermaid.js)

Passes Mermaid source through unchanged so a diagram renderer can process it later.

graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Do something]
    B -->|No| D[Do something else]
    C --> E[End]
    D --> E
How to build this
mermaid

Regex Markers

Marks text that matches regular expressions, including inserted and deleted match styles.

Goregex-markers.go
func fetchUsers() ([]User, error) {
resp, err := http.Get("/api/users")
if err != nil {
return nil, fmt.Errorf("fetchUsers failed: %w", err)
}
defer resp.Body.Close()
var users []User
json.NewDecoder(resp.Body).Decode(&users)
return users, nil
}
How to build this
go title="regex-markers.go" showLineNumbers /err\b/ ins=/func\s+\w+/ del=/fmt\.Errorf/

Regex Capture Group (/ye(s|p)/ marks only "s" or "p")

Highlights only the captured subgroup of a regular-expression match instead of the full match.

Pythoncapture_group.py
haystack = "yes"
confirm = "yep"
reject = "nope"
How to build this
python title="capture_group.py" /ye(s|p)/

Hybrid Diff + Syntax Highlighting (diff lang="go")

Combines diff prefixes with syntax highlighting from the underlying source language.

Gohybrid-diff.go
import (
"fmt"
"log"
"os"
)
func main() {
fmt.Println("hello")
log.Println("hello")
}
How to build this
diff lang="go" title="hybrid-diff.go" showLineNumbers

Code Group (tabbed code blocks via Goldmark)

Presents related language examples as an accessible tabbed group generated from Markdown.

Gomain.go
package main
import "fmt"
func main() {
fmt.Println("Hello from Go!")
}
How to build this

Markdown

:::code-group

```go title="main.go"
package main

import "fmt"

func main() {
	fmt.Println("Hello from Go!")
}
```

```python title="main.py"
def main():
    print("Hello from Python!")

if __name__ == "__main__":
    main()
```

```javascript title="index.js"
function main() {
  console.log("Hello from JavaScript!");
}

main();
```

:::

Code Group Tab Sync (tabs synced across groups)

Synchronizes matching tabs across separate code groups that share the same key.

Go
go get github.com/example/pkg
Go
import "github.com/example/pkg"
Linux
sudo apt install build-essential
How to build this

Markdown

:::code-group sync="language"

```go
go get github.com/example/pkg
```

```python
pip install example-pkg
```

```javascript
npm install example-pkg
```

:::

<p>Select a language above and the group below syncs automatically.</p>

:::code-group sync="language"

```go
import "github.com/example/pkg"
```

```python
import example_pkg
```

```javascript
const pkg = require('example-pkg');
```

:::

<p>This group uses a different sync key (<code>sync="platform"</code>) and syncs independently.</p>

:::code-group sync="platform"

```bash title="Linux"
sudo apt install build-essential
```

```powershell title="Windows"
winget install Microsoft.VisualStudio.BuildTools
```

```bash title="macOS"
brew install gcc
```

:::

ANSI Terminal Output

Renders ANSI SGR escape sequences into styled HTML with full color and text decoration support.

ANSI Escape Sequences (parsed SGR codes)

Converts ANSI SGR escape sequences into styled terminal colors and text treatments.

server.log
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
ansi title="server.log" showLineNumbers

ANSI Git Diff (16-color foreground + background)

Renders git diff output with bold headers, cyan hunk markers, and red/green background strips for deleted and inserted lines.

git diff
diff --git a/api/handler.go b/api/handler.go
index 4e9d2a1..7c3f8b2 100644
--- a/api/handler.go
+++ b/api/handler.go
@@ -12,7 +12,9 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
- log.Printf("request: %s %s", r.Method, r.URL.Path)
+ spanCtx, span := tracer.Start(ctx, "ServeHTTP")
+ defer span.End()
+ log.Printf("trace: %s %s", r.Method, r.URL.Path)
handler(w, r.WithContext(ctx))
How to build this
ansi title="git diff" showLineNumbers

ANSI Truecolor + Styles (24-bit RGB, italic, strikethrough, underline)

Demonstrates 24-bit truecolor foregrounds alongside italic, bold, strikethrough, and underline text styles.

cargo build
WARNING cargo build
Compiling tokio v1.36.0
deprecated: use tokio::task::spawn_local instead
ERROR[E0308] mismatched types
expected &str
found String
For more information: rustc --explain E0308
How to build this
ansi title="cargo build" showLineNumbers

ANSI 256-Color Palette (cube, grayscale, background)

Exercises all three 256-color zones: the standard palette, the 6x6x6 color cube, and the grayscale ramp.

ls --color
/home/user/project
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
Total: 7 items
How to build this
ansi title="ls --color" showLineNumbers

Themes and Customization

Per-block themes, generated adjustments, and scoped CSS output.

Per-Block Theme Override (default vs dracula)

Selects an alternate theme for one block without changing the rest of the page.

Godefault theme
func main() {
fmt.Println("Same code, different theme")
}
Gotheme=dracula
func main() {
fmt.Println("Same code, different theme")
}
How to build this
go title="default theme" showLineNumbers
go title="theme=dracula" showLineNumbers theme="dracula"

Per-Block Theme Override (dual: dracula + github-light)

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.

Gotheme=dracula,github-light
func main() {
fmt.Println("Same code, different theme")
}
How to build this
go title="theme=dracula,github-light" showLineNumbers theme="dracula,github-light"

Theme Customizer (dark BG changed to #1a1b26)

Adjusts resolved theme colors through a callback before Kazari generates the CSS variables.

Gocustomized-theme.go
fmt.Println("Custom dark BG: #1a1b26")
How to build this

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)

Applies an OKLCH tint to generated theme colors while preserving their visual relationships.

Gotinted-theme.go
fmt.Println("Backgrounds tinted toward teal in OKLCH space")
How to build this

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)

Emits theme variables beneath a custom selector so Kazari styles stay inside a chosen container.

Goscoped.go
fmt.Println("CSS vars scoped to .kazari-scoped")
How to build this

Go

engine := kazari.New(kazari.WithThemeCSSRoot(".kazari-scoped"))
css := engine.CSS()

Per-Block Theme Toggle

Adds a per-block toggle button that lets readers switch an individual code block between light and dark themes independently of the page.

Gotheme-toggle.go
func main() {
fmt.Println("Toggle this block's theme!")
}
JavaScriptdemo.js
const greeting = "Each block toggles independently";
console.log(greeting);
How to build this

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"))

Localizes built-in copy and fullscreen controls through the engine's locale setting.

Golocale-fr.go
fmt.Println("Bonjour le monde !")
How to build this

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)

Resolves a custom icon from each title's file extension and places it in the frame toolbar.

Go🔵main.go
fmt.Println("Go")
Python🐍app.py
print("Python")
JavaScript🟡index.js
console.log("JS")
Rust🦀main.rs
fn main() {}
How to build this

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)

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.

fmt.Println("Go")
print("Python")
console.log("JS")
How to build this

Go

engine := kazari.New(kazari.WithLanguageIconMode(kazari.LangIconOnly))

Language Icons: Icon + Text (LangIconAndText)

Shows a language icon before the text label, giving both a visual cue and a readable name. Color SVG icons are available from Devicon.

Go
fmt.Println("Go")
Python
print("Python")
JavaScript
console.log("JS")
How to build this

Go

engine := kazari.New(kazari.WithLanguageIconMode(kazari.LangIconAndText))

Output Panel

Separate command output from highlighted source code.

Basic Output Panel

Separates terminal commands from their output in a linked panel below the highlighted code.

Terminal window
pwd
ls -la
/usr/home/boba-tan
total 24
drwxr-xr-x  3 boba boba 4096 Jun 28 14:30 .
How to build this
bash withOutput

Editor Frame Output

Attaches program output beneath an editor-framed source block with an explicit file title.

Gomain.go
package main
import "fmt"
func main() {
fmt.Println("Hello, Kazari!")
fmt.Println("Output panels are here.")
}
Hello, Kazari!
Output panels are here.
How to build this
go withOutput

Collapsed Output

Starts the output panel hidden so readers can focus on the code and reveal output on demand.

Terminal window
echo "Build complete"
Build complete
How to build this
bash withOutput outputCollapsed

Custom Label

Replaces the default toggle label with a descriptive name that fits the example context.

Terminal window
node index.js
Server listening on port 3000
How to build this
bash withOutput outputLabel="Run result"

Post-Render Callbacks

Extend rendered output with WithPostRender callbacks.

TODO/FIXME Badges

Injects warning badges next to TODO and FIXME comments using a WithPostRender callback.

Goserver.go
package main
import "net/http"
func main() {
// TODO add TLS configuration
http.HandleFunc("/", handler)
// FIXME this ignores the returned error
http.ListenAndServe(":8080", nil)
}
How to build this

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),
)

Figure Caption

Wraps the code block in a figure element with a caption derived from the block title.

Goconfig.go
package config
type Server struct {
Host string
Port int
TLS bool
}
config.go
How to build this

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),
)