You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
gitea/vendor/github.com/yuin/goldmark-highlighting
mrsdizzie af7ffaa279
Server-side syntax highlighting for all code (#12047)
4 years ago
..
.gitignore Server-side syntax highlighting for all code (#12047) 4 years ago
LICENSE Server-side syntax highlighting for all code (#12047) 4 years ago
README.md Server-side syntax highlighting for all code (#12047) 4 years ago
go.mod Server-side syntax highlighting for all code (#12047) 4 years ago
go.sum Server-side syntax highlighting for all code (#12047) 4 years ago
highlighting.go Server-side syntax highlighting for all code (#12047) 4 years ago

README.md

goldmark-highlighting

goldmark-highlighting is an extension for the goldmark that adds syntax-highlighting to the fenced code blocks.

goldmark-highlighting uses chroma as a syntax highlighter.

Installation

go get github.com/yuin/goldmark-highlighting

Usage

import (
    "bytes"
    "fmt"
    "github.com/alecthomas/chroma/formatters/html"
    "github.com/yuin/goldmark"
    "github.com/yuin/goldmark/extension"
    "github.com/yuin/goldmark/parser"
    "github.com/yuin/goldmark-highlighting"

)

func main() {
    markdown := goldmark.New(
        goldmark.WithExtensions(
            highlighting.Highlighting,
        ),
    )
    var buf bytes.Buffer
    if err := markdown.Convert([]byte(source), &buf); err != nil {
        panic(err)
    }
    fmt.Print(title)
}
    markdown := goldmark.New(
        goldmark.WithExtensions(
            highlighting.NewHighlighting(
               highlighting.WithStyle("monokai"),
               highlighting.WithFormatOptions(
                   html.WithLineNumbers(),
               ),
            ),
        ),
    )

License

MIT

Author

Yusuke Inuzuka