package html
import "github.com/yuin/goldmark/renderer/html"
Package html implements renderer that outputs HTMLs.
Index ¶
- Variables
- func IsDangerousURL(url []byte) bool
- func NewRenderer(opts ...Option) renderer.NodeRenderer
- func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)
- func WithEastAsianLineBreaks(e EastAsianLineBreaks) interface { renderer.Option Option }
- func WithHardWraps() interface { renderer.Option Option }
- func WithUnsafe() interface { renderer.Option Option }
- func WithWriter(writer Writer) interface { renderer.Option Option }
- func WithXHTML() interface { Option renderer.Option }
- type Config
- type EastAsianLineBreaks
- type Option
- type Renderer
- type Writer
- type WriterConfig
- type WriterOption
Variables ¶
var BlockquoteAttributeFilter = GlobalAttributeFilter.ExtendString(`cite`)
BlockquoteAttributeFilter defines attribute names which blockquote elements can have.
var CodeAttributeFilter = GlobalAttributeFilter
CodeAttributeFilter defines attribute names which code elements can have.
var DefaultWriter = NewWriter()
DefaultWriter is a default instance of the Writer.
var EmphasisAttributeFilter = GlobalAttributeFilter
EmphasisAttributeFilter defines attribute names which emphasis elements can have.
var GlobalAttributeFilter = util.NewBytesFilterString("" /* 219 byte string literal not displayed */)
GlobalAttributeFilter defines attribute names which any elements can have.
var HeadingAttributeFilter = GlobalAttributeFilter
HeadingAttributeFilter defines attribute names which heading elements can have.
var ImageAttributeFilter = GlobalAttributeFilter.ExtendString(`align,border,crossorigin,decoding,height,importance,intrinsicsize,ismap,loading,referrerpolicy,sizes,srcset,usemap,width`) // nolint: lll
ImageAttributeFilter defines attribute names which image elements can have.
var LinkAttributeFilter = GlobalAttributeFilter.ExtendString(`download,hreflang,media,ping,referrerpolicy,rel,shape,target`) // nolint:lll
LinkAttributeFilter defines attribute names which link elements can have.
var ListAttributeFilter = GlobalAttributeFilter.ExtendString(`start,reversed,type`)
ListAttributeFilter defines attribute names which list elements can have.
var ListItemAttributeFilter = GlobalAttributeFilter.ExtendString(`value`)
ListItemAttributeFilter defines attribute names which list item elements can have.
var ParagraphAttributeFilter = GlobalAttributeFilter
ParagraphAttributeFilter defines attribute names which paragraph elements can have.
var ThematicAttributeFilter = GlobalAttributeFilter.ExtendString(`align,color,noshade,size,width`)
ThematicAttributeFilter defines attribute names which hr elements can have.
Functions ¶
func IsDangerousURL ¶
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 RenderAttributes ¶
RenderAttributes renders given node's attributes. You can specify attribute names to render by the filter. If filter is nil, RenderAttributes renders all attributes.
func WithEastAsianLineBreaks ¶
func WithEastAsianLineBreaks(e EastAsianLineBreaks) interface { renderer.Option Option }
WithEastAsianLineBreaks is a functional option that indicates whether softline breaks between east asian wide characters should be ignored.
func WithHardWraps ¶
WithHardWraps is a functional option that indicates whether softline breaks should be rendered as '<br>'.
func WithUnsafe ¶
WithUnsafe is a functional option that renders dangerous contents (raw htmls and potentially dangerous links) as it is.
func WithWriter ¶
WithWriter is a functional option that allow you to set the given writer to the renderer.
func WithXHTML ¶
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 EastAsianLineBreaks EastAsianLineBreaks 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 EastAsianLineBreaks ¶
type EastAsianLineBreaks int
A EastAsianLineBreaks is a style of east asian line breaks.
const ( //EastAsianLineBreaksNone renders line breaks as it is. EastAsianLineBreaksNone EastAsianLineBreaks = iota // EastAsianLineBreaksSimple follows east_asian_line_breaks in Pandoc. EastAsianLineBreaksSimple // EastAsianLineBreaksCSS3Draft follows CSS text level3 "Segment Break Transformation Rules" with some enhancements. EastAsianLineBreaksCSS3Draft )
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 .
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 writes the given source to writer without resolving references and // unescaping backslash escaped characters. RawWrite(writer util.BufWriter, source []byte) // SecureWrite writes the given source to writer with replacing insecure characters. SecureWrite(writer util.BufWriter, source []byte) }
A Writer interface writes textual contents to a writer.
func NewWriter ¶
func NewWriter(opts ...WriterOption) Writer
NewWriter returns a new Writer.
type WriterConfig ¶
type WriterConfig struct { // EscapedSpace is an option that indicates that a '\' escaped half-space(0x20) should not be rendered. EscapedSpace bool }
A WriterConfig struct has configurations for the HTML based writers.
type WriterOption ¶
type WriterOption func(*WriterConfig)
A WriterOption interface sets options for HTML based writers.
func WithEscapedSpace ¶
func WithEscapedSpace() WriterOption
WithEscapedSpace is a WriterOption indicates that a '\' escaped half-space(0x20) should not be rendered.
Source Files ¶
- Version
- v1.7.9
- Published
- Apr 14, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 17 hours ago –
Tools for package owners.