code

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package code registers the source-code renderer with the stripes registry. Import for side effects to enable text/x-source-code support and chroma's filename-based language detection in stripes.Detect:

import _ "github.com/firetiger-oss/stripes/code"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(lang string) stripes.Renderer

New returns a stripes.Renderer that highlights source code using the chroma lexer named lang. When lang is empty the renderer falls back to chroma's content-based language detection; if no lexer can be resolved the input is written verbatim.

func RenderWasm

func RenderWasm(w io.Writer, r io.Reader, styles *stripes.Styles)

RenderWasm writes a styled rendering of the binary WebAssembly module (application/wasm) read from r to w. It disassembles the input by invoking an external tool and highlights the resulting WAT text with chroma's wat lexer.

The preferred backend is "wasm-tools print" from the bytecodealliance (https://github.com/bytecodealliance/wasm-tools), which tracks the current WebAssembly specification including the component model. When wasm-tools is not on $PATH, RenderWasm falls back to "wasm2wat" from WABT (https://github.com/WebAssembly/wabt). When neither is available, RenderWasm writes a single-line diagnostic instead of failing silently. Install via "cargo install wasm-tools" or "brew install wasm-tools"; install WABT via "brew install wabt" or "apt install wabt".

Types

This section is empty.

Jump to

Keyboard shortcuts

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