hugo: github.com/gohugoio/hugo/markup/highlight Index | Files

package highlight

import "github.com/gohugoio/hugo/markup/highlight"

Package highlight provides code highlighting.

Index

Package Files

config.go highlight.go

Variables

var DefaultConfig = Config{

    Style:              "monokai",
    LineNoStart:        1,
    CodeFences:         true,
    NoClasses:          true,
    LineNumbersInTable: true,
    TabWidth:           4,
}

func ApplyLegacyConfig Uses

func ApplyLegacyConfig(cfg config.Provider, conf *Config) error

ApplyLegacyConfig applies legacy config from back when we had Pygments.

func GetCodeBlockOptions Uses

func GetCodeBlockOptions() func(ctx hl.CodeBlockContext) []html.Option

func WriteCodeTag Uses

func WriteCodeTag(w io.Writer, language string)

type Config Uses

type Config struct {
    Style string

    CodeFences bool

    // Use inline CSS styles.
    NoClasses 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

    // TabWidth sets the number of characters for a tab. Defaults to 4.
    TabWidth int

    GuessSyntax bool
}

func (Config) ToHTMLOptions Uses

func (cfg Config) ToHTMLOptions() []html.Option

type Highlighter Uses

type Highlighter struct {
    // contains filtered or unexported fields
}

func New Uses

func New(cfg Config) Highlighter

func (Highlighter) Highlight Uses

func (h Highlighter) Highlight(code, lang, optsStr string) (string, error)

Package highlight imports 12 packages (graph) and is imported by 13 packages. Updated 2020-10-01. Refresh now. Tools for package owners.