highlight

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package highlight renders syntax-highlighted code frames (REQ-CNT-04). Chroma runs at build time; the browser gets HTML and CSS only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeCSS

func CodeCSS() string

CodeCSS returns the light and dark stylesheet of the highlighted code blocks (REQ-CNT-04). Token colours are CSS variables.

func LangForFile

func LangForFile(path string) string

LangForFile guesses the chroma lexer name from a file path.

func ParseLines

func ParseLines(s string) []int

ParseLines parses "1,3-5" into line numbers.

func RenderCode

func RenderCode(lang, info, code string) string

RenderCode renders one highlighted code block.

Types

type Options

type Options struct {
	Lang  string
	Title string
	// Frame is "" (none), "code" or "terminal".
	Frame string
	// Marks, Ins, Del and Words hold 1-based line numbers.
	Marks []int
	Ins   []int
	Del   []int
	Words []int
	Wrap  bool
}

Options are the options of one highlighted code block.

func ParseInfo

func ParseInfo(lang, info string) Options

ParseInfo parses the fence info string (REQ-CNT-04):

```go title="main.go" frame="code" {3-5} ins={7} del={9} word={2} wrap

Jump to

Keyboard shortcuts

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