Documentation ¶
Overview ¶
Package highlight provides code highlighting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{ Style: "monokai", LineNoStart: 1, CodeFences: true, NoClasses: true, LineNumbersInTable: true, TabWidth: 4, }
Functions ¶
func ApplyLegacyConfig ¶
ApplyLegacyConfig applies legacy config from back when we had Pygments.
func WritePreEnd ¶ added in v0.88.0
func WritePreStart ¶ added in v0.88.0
Types ¶
type Config ¶
type Config struct { Style string CodeFences bool // Use inline CSS styles. NoClasses bool // No highlighting. NoHl bool // When set, line numbers will be printed. LineNos bool LineNumbersInTable bool // When set, add links to line numbers AnchorLineNos bool LineAnchors string // Start the line numbers from this value (default is 1). LineNoStart int // A space separated list of line numbers, e.g. “3-8 10-20”. Hl_Lines string // A parsed and ready to use list of line ranges. HL_lines_parsed [][2]int `json:"-"` // TabWidth sets the number of characters for a tab. Defaults to 4. TabWidth int GuessSyntax bool }
func (Config) ToHTMLOptions ¶
type Highlighter ¶
type Highlighter interface { Highlight(code, lang string, opts any) (string, error) HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HightlightResult, error) hooks.CodeBlockRenderer hooks.IsDefaultCodeBlockRendererProvider }
func New ¶
func New(cfg Config) Highlighter
type HightlightResult ¶ added in v0.93.0
type HightlightResult struct {
// contains filtered or unexported fields
}
func (HightlightResult) Inner ¶ added in v0.93.0
func (h HightlightResult) Inner() template.HTML
func (HightlightResult) Wrapped ¶ added in v0.93.0
func (h HightlightResult) Wrapped() template.HTML
Click to show internal directories.
Click to hide internal directories.