Socket
Socket
Sign inDemoInstall

github.com/yuin/goldmark-highlighting

Package Overview
Dependencies
2
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/yuin/goldmark-highlighting

package highlighting is a extension for the goldmark(http://github.com/yuin/goldmark). This extension adds syntax-highlighting to the fenced code blocks using chroma(https://github.com/alecthomas/chroma).


Version published

Readme

Source

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.

Deprecated

This branch(master) uses chroma v1 as a syntax highlighter.

Now goldmark-highlighting uses chroma v2 as a syntax highlighter and defaults to v2 branch.

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

FAQs

Last updated on 24 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc