adapter

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package adapter provides convenient adapters for other popular packages making it simple to use those as nb extensions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnsiHtml

func AnsiHtml(convert func([]byte) []byte) render.RenderCellFunc

AnsiHtml wraps ansihtml-style function in RenderCellFunc.

Usage:

extension.NewStream(
	adapter.AnsiHtml(ansihtml.ConvertToHTML)
)

To force ansihtml to use classes instead of inline styles, pass an anonymous function intead:

extension.NewStream(
	adapter.AnsiHtml(func([]byte) []byte) {
		ansihtml.ConvertToHTMLWithClasses(b, "class-", false)
	})
)

func Blackfriday

func Blackfriday(convert func([]byte) []byte) render.RenderCellFunc

Blackfriday wraps blackfriday-style function in RenderCellFunc.

Usage:

extension.NewMarkdown(
	adapter.Blackfriday(blackfriday.MarkdownCommon)
)

func Goldmark

func Goldmark(write func([]byte, io.Writer) error) render.RenderCellFunc

Goldmark wraps goldmark-style function in RenderCellFunc.

Usage:

extension.NewMarkdown(
	adapter.Goldmark(func(b []byte, w io.Writer) error {
		return goldmark.Convert(b, w, parseOptions...)
	})
)

Notice, how Goldmark is a bit more verbose compared to Blackfriday: this is because goldmark.Convert accepts variadic parser.ParseOptions, which is a dependency the client should capture in the closure and pass manually.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL