• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D07-Mar-2020200

LICENSEH A D07-Mar-20201 KiB

README.mdH A D07-Mar-20201.3 KiB

go.modH A D07-Mar-2020481

go.sumH A D07-Mar-20205.4 KiB

highlighting.goH A D07-Mar-202014.8 KiB

highlighting_test.goH A D07-Mar-202011.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