html

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 6 Imported by: 509

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultWriter = &defaultWriter{}

DefaultWriter is a default implementation of the Writer.

Functions

func IsDangerousURL

func IsDangerousURL(url []byte) bool

IsDangerousURL returns true if the given url seems a potentially dangerous url, otherwise false.

func NewRenderer

func NewRenderer(opts ...Option) renderer.NodeRenderer

NewRenderer returns a new Renderer with given options.

func WithHardWraps

func WithHardWraps() interface {
	renderer.Option
	Option
}

WithHardWraps is a functional option that indicates whether softline breaks should be rendered as '<br>'.

func WithUnsafe

func WithUnsafe() interface {
	renderer.Option
	Option
}

WithUnsafe is a functional option that renders dangerous contents (raw htmls and potentially dangerous links) as it is.

func WithWriter

func WithWriter(writer Writer) interface {
	renderer.Option
	Option
}

WithWriter is a functional option that allow you to set the given writer to the renderer.

func WithXHTML

func WithXHTML() interface {
	Option
	renderer.Option
}

WithXHTML is a functional option indicates that nodes should be rendered in xhtml instead of HTML5.

Types

type Config

type Config struct {
	Writer    Writer
	HardWraps bool
	XHTML     bool
	Unsafe    bool
}

A Config struct has configurations for the HTML based renderers.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with defaults.

func (*Config) SetOption

func (c *Config) SetOption(name renderer.OptionName, value interface{})

SetOption implements renderer.NodeRenderer.SetOption.

type Option

type Option interface {
	SetHTMLOption(*Config)
}

An Option interface sets options for HTML based renderers.

type Renderer

type Renderer struct {
	Config
}

A Renderer struct is an implementation of renderer.NodeRenderer that renders nodes as (X)HTML.

func (*Renderer) RegisterFuncs

func (r *Renderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs implements NodeRenderer.RegisterFuncs .

func (*Renderer) RenderAttributes

func (r *Renderer) RenderAttributes(w util.BufWriter, node ast.Node)

RenderAttributes renders given node's attributes.

type Writer

type Writer interface {
	// Write writes the given source to writer with resolving references and unescaping
	// backslash escaped characters.
	Write(writer util.BufWriter, source []byte)

	// RawWrite wirtes the given source to writer without resolving references and
	// unescaping backslash escaped characters.
	RawWrite(writer util.BufWriter, source []byte)
}

A Writer interface wirtes textual contents to a writer.

Jump to

Keyboard shortcuts

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