Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
.gitignore | H A D | 07-Mar-2020 | 200 | |||
LICENSE | H A D | 07-Mar-2020 | 1 KiB | |||
README.md | H A D | 07-Mar-2020 | 1.3 KiB | |||
go.mod | H A D | 07-Mar-2020 | 481 | |||
go.sum | H A D | 07-Mar-2020 | 5.4 KiB | |||
highlighting.go | H A D | 07-Mar-2020 | 14.8 KiB | |||
highlighting_test.go | H A D | 07-Mar-2020 | 11.6 KiB |
README.md
1goldmark-highlighting 2========================= 3 4goldmark-highlighting is an extension for the [goldmark](http://github.com/yuin/goldmark) 5that adds syntax-highlighting to the fenced code blocks. 6 7goldmark-highlighting uses [chroma](https://github.com/alecthomas/chroma) as a 8syntax highlighter. 9 10Installation 11-------------------- 12 13``` 14go get github.com/yuin/goldmark-highlighting 15``` 16 17Usage 18-------------------- 19 20```go 21import ( 22 "bytes" 23 "fmt" 24 "github.com/alecthomas/chroma/formatters/html" 25 "github.com/yuin/goldmark" 26 "github.com/yuin/goldmark/extension" 27 "github.com/yuin/goldmark/parser" 28 "github.com/yuin/goldmark-highlighting" 29 30) 31 32func main() { 33 markdown := goldmark.New( 34 goldmark.WithExtensions( 35 highlighting.Highlighting, 36 ), 37 ) 38 var buf bytes.Buffer 39 if err := markdown.Convert([]byte(source), &buf); err != nil { 40 panic(err) 41 } 42 fmt.Print(title) 43} 44``` 45 46 47```go 48 markdown := goldmark.New( 49 goldmark.WithExtensions( 50 highlighting.NewHighlighting( 51 highlighting.WithStyle("monokai"), 52 highlighting.WithFormatOptions( 53 html.WithLineNumbers(), 54 ), 55 ), 56 ), 57 ) 58``` 59 60License 61-------------------- 62MIT 63 64Author 65-------------------- 66Yusuke Inuzuka 67