renderer

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadFile = errors.New("file reading error")
	ErrTpl      = errors.New("template error")
)

Functions

This section is empty.

Types

type Config

type Config interface {
	CodeDefaultLang() string
	SyntaxTheme() string
	TmplConf() *config.Template
}

type Logger

type Logger interface {
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

type Options

type Options struct {
	html.RendererOptions

	SyntaxDefaultLang string
	SyntaxTheme       string
	TmplConf          *config.Template
}

type Page

type Page struct {
	Title    string
	Filename string
	Body     template.HTML
	*config.Template
}

type Renderer

type Renderer struct {
	*html.Renderer
	// contains filtered or unexported fields
}

func NewDefaultRenderer

func NewDefaultRenderer(conf Config, logger Logger) (*Renderer, error)

func NewRenderer

func NewRenderer(opts Options, logger Logger) (*Renderer, error)

func (*Renderer) Code

func (r *Renderer) Code(w io.Writer, code *ast.Code)

Code renders code tag with syntax highlighting.

func (*Renderer) CodeBlock

func (r *Renderer) CodeBlock(w io.Writer, codeBlock *ast.CodeBlock)

CodeBlock renders code block with syntax highlighting.

func (*Renderer) DocumentMatter

func (r *Renderer) DocumentMatter(w io.Writer, node *ast.DocumentMatter, entering bool)

DocumentMatter just copies parent method using child's `state` property

func (*Renderer) Image

func (r *Renderer) Image(w io.Writer, node *ast.Image, entering bool)

Image renders img tag without trailing slash to match w3c recommendation

func (r *Renderer) Link(w io.Writer, link *ast.Link, entering bool)

Link converts .md links to .html links and adds starting slash to local pages.

func (*Renderer) RenderFooter

func (r *Renderer) RenderFooter(w io.Writer, _ ast.Node)

RenderFooter writes HTML document footer.

func (*Renderer) RenderNode

func (r *Renderer) RenderNode(w io.Writer, node ast.Node, entering bool) ast.WalkStatus

RenderNode process images, links, and code blocks differently than default renderer

func (*Renderer) RenderPage

func (r *Renderer) RenderPage(mdFilename string) ([]byte, error)

Jump to

Keyboard shortcuts

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