extension

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 13 Imported by: 680

Documentation

Overview

Package extension is a collection of builtin extensions.

Index

Constants

This section is empty.

Variables

CJK is a goldmark extension that provides functionalities for CJK languages.

View Source
var DefinitionDescriptionAttributeFilter = html.GlobalAttributeFilter

DefinitionDescriptionAttributeFilter defines attribute names which dd elements can have.

View Source
var DefinitionList = &definitionList{}

DefinitionList is an extension that allow you to use PHP Markdown Extra Definition lists.

View Source
var DefinitionListAttributeFilter = html.GlobalAttributeFilter

DefinitionListAttributeFilter defines attribute names which dl elements can have.

View Source
var DefinitionTermAttributeFilter = html.GlobalAttributeFilter

DefinitionTermAttributeFilter defines attribute names which dd elements can have.

View Source
var Footnote = &footnote{
	options: []FootnoteOption{},
}

Footnote is an extension that allow you to use PHP Markdown Extra Footnotes.

View Source
var GFM = &gfm{}

GFM is an extension that provides Github Flavored markdown functionalities.

View Source
var Linkify = &linkify{}

Linkify is an extension that allow you to parse text that seems like a URL.

View Source
var Strikethrough = &strikethrough{}

Strikethrough is an extension that allow you to use strikethrough expression like '~~text~~' .

View Source
var StrikethroughAttributeFilter = html.GlobalAttributeFilter

StrikethroughAttributeFilter defines attribute names which dd elements can have.

View Source
var Table = &table{
	options: []TableOption{},
}

Table is an extension that allow you to use GFM tables .

View Source
var TableAttributeFilter = html.GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("bgcolor"),
	[]byte("border"),
	[]byte("cellpadding"),
	[]byte("cellspacing"),
	[]byte("frame"),
	[]byte("rules"),
	[]byte("summary"),
	[]byte("width"),
)

TableAttributeFilter defines attribute names which table elements can have.

View Source
var TableHeaderAttributeFilter = html.GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("bgcolor"),
	[]byte("char"),
	[]byte("charoff"),
	[]byte("valign"),
)

TableHeaderAttributeFilter defines attribute names which <thead> elements can have.

View Source
var TableRowAttributeFilter = html.GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("bgcolor"),
	[]byte("char"),
	[]byte("charoff"),
	[]byte("valign"),
)

TableRowAttributeFilter defines attribute names which <tr> elements can have.

View Source
var TableTdCellAttributeFilter = html.GlobalAttributeFilter.Extend(
	[]byte("abbr"),
	[]byte("align"),
	[]byte("axis"),
	[]byte("bgcolor"),
	[]byte("char"),
	[]byte("charoff"),

	[]byte("colspan"),
	[]byte("headers"),

	[]byte("height"),

	[]byte("rowspan"),

	[]byte("scope"),
	[]byte("valign"),
	[]byte("width"),
)

TableTdCellAttributeFilter defines attribute names which table <td> cells can have.

View Source
var TableThCellAttributeFilter = html.GlobalAttributeFilter.Extend(
	[]byte("abbr"),

	[]byte("align"),
	[]byte("axis"),
	[]byte("bgcolor"),
	[]byte("char"),
	[]byte("charoff"),

	[]byte("colspan"),
	[]byte("headers"),

	[]byte("height"),

	[]byte("rowspan"),
	[]byte("scope"),

	[]byte("valign"),
	[]byte("width"),
)

TableThCellAttributeFilter defines attribute names which table <th> cells can have.

View Source
var TaskList = &taskList{}

TaskList is an extension that allow you to use GFM task lists.

View Source
var Typographer = &typographer{}

Typographer is an extension that replaces punctuations with typographic entities.

Functions

func NewCJK added in v1.5.0

func NewCJK(opts ...CJKOption) goldmark.Extender

NewCJK returns a new extension with given options.

func NewDefinitionDescriptionParser

func NewDefinitionDescriptionParser() parser.BlockParser

NewDefinitionDescriptionParser return a new parser.BlockParser that can parse definition description starts with ':'.

func NewDefinitionListHTMLRenderer

func NewDefinitionListHTMLRenderer(opts ...html.Option) renderer.NodeRenderer

NewDefinitionListHTMLRenderer returns a new DefinitionListHTMLRenderer.

func NewDefinitionListParser

func NewDefinitionListParser() parser.BlockParser

NewDefinitionListParser return a new parser.BlockParser that can parse PHP Markdown Extra Definition lists.

func NewFootnote added in v1.3.0

func NewFootnote(opts ...FootnoteOption) goldmark.Extender

NewFootnote returns a new extension with given options.

func NewFootnoteASTTransformer

func NewFootnoteASTTransformer() parser.ASTTransformer

NewFootnoteASTTransformer returns a new parser.ASTTransformer that insert a footnote list to the last of the document.

func NewFootnoteBlockParser

func NewFootnoteBlockParser() parser.BlockParser

NewFootnoteBlockParser returns a new parser.BlockParser that can parse footnotes of the Markdown(PHP Markdown Extra) text.

func NewFootnoteHTMLRenderer

func NewFootnoteHTMLRenderer(opts ...FootnoteOption) renderer.NodeRenderer

NewFootnoteHTMLRenderer returns a new FootnoteHTMLRenderer.

func NewFootnoteParser

func NewFootnoteParser() parser.InlineParser

NewFootnoteParser returns a new parser.InlineParser that can parse footnote links of the Markdown(PHP Markdown Extra) text.

func NewLinkify added in v1.1.20

func NewLinkify(opts ...LinkifyOption) goldmark.Extender

NewLinkify creates a new goldmark.Extender that allow you to parse text that seems like a URL.

func NewLinkifyParser

func NewLinkifyParser(opts ...LinkifyOption) parser.InlineParser

NewLinkifyParser return a new InlineParser can parse text that seems like a URL.

func NewStrikethroughHTMLRenderer

func NewStrikethroughHTMLRenderer(opts ...html.Option) renderer.NodeRenderer

NewStrikethroughHTMLRenderer returns a new StrikethroughHTMLRenderer.

func NewStrikethroughParser

func NewStrikethroughParser() parser.InlineParser

NewStrikethroughParser return a new InlineParser that parses strikethrough expressions.

func NewTable added in v1.2.0

func NewTable(opts ...TableOption) goldmark.Extender

NewTable returns a new extension with given options.

func NewTableASTTransformer added in v1.3.1

func NewTableASTTransformer() parser.ASTTransformer

NewTableASTTransformer returns a parser.ASTTransformer for tables.

func NewTableHTMLRenderer

func NewTableHTMLRenderer(opts ...TableOption) renderer.NodeRenderer

NewTableHTMLRenderer returns a new TableHTMLRenderer.

func NewTableParagraphTransformer

func NewTableParagraphTransformer() parser.ParagraphTransformer

NewTableParagraphTransformer returns a new ParagraphTransformer that can transform paragraphs into tables.

func NewTaskCheckBoxHTMLRenderer

func NewTaskCheckBoxHTMLRenderer(opts ...html.Option) renderer.NodeRenderer

NewTaskCheckBoxHTMLRenderer returns a new TaskCheckBoxHTMLRenderer.

func NewTaskCheckBoxParser

func NewTaskCheckBoxParser() parser.InlineParser

NewTaskCheckBoxParser returns a new InlineParser that can parse checkboxes in list items. This parser must take precedence over the parser.LinkParser.

func NewTypographer

func NewTypographer(opts ...TypographerOption) goldmark.Extender

NewTypographer returns a new Extender that replaces punctuations with typographic entities.

func NewTypographerParser

func NewTypographerParser(opts ...TypographerOption) parser.InlineParser

NewTypographerParser return a new InlineParser that parses typographer expressions.

Types

type CJKOption added in v1.5.0

type CJKOption func(*cjk)

A CJKOption sets options for CJK support mostly for HTML based renderers.

func WithEastAsianLineBreaks added in v1.5.0

func WithEastAsianLineBreaks(style ...EastAsianLineBreaks) CJKOption

WithEastAsianLineBreaks is a functional option that indicates whether softline breaks between east asian wide characters should be ignored. style defauts to EastAsianLineBreaksSimple .

func WithEscapedSpace added in v1.5.0

func WithEscapedSpace() CJKOption

WithEscapedSpace is a functional option that indicates that a '\' escaped half-space(0x20) should not be rendered.

type DefinitionListHTMLRenderer

type DefinitionListHTMLRenderer struct {
	html.Config
}

DefinitionListHTMLRenderer is a renderer.NodeRenderer implementation that renders DefinitionList nodes.

func (*DefinitionListHTMLRenderer) RegisterFuncs

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type EastAsianLineBreaks added in v1.6.0

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 is a style where soft line breaks are ignored
	// if both sides of the break are east asian wide characters.
	EastAsianLineBreaksSimple
	// EastAsianLineBreaksCSS3Draft is a style where soft line breaks are ignored
	// even if only one side of the break is an east asian wide character.
	EastAsianLineBreaksCSS3Draft
)

type FootnoteConfig added in v1.3.0

type FootnoteConfig struct {
	html.Config

	// IDPrefix is a prefix for the id attributes generated by footnotes.
	IDPrefix []byte

	// IDPrefix is a function that determines the id attribute for given Node.
	IDPrefixFunction func(gast.Node) []byte

	// LinkTitle is an optional title attribute for footnote links.
	LinkTitle []byte

	// BacklinkTitle is an optional title attribute for footnote backlinks.
	BacklinkTitle []byte

	// LinkClass is a class for footnote links.
	LinkClass []byte

	// BacklinkClass is a class for footnote backlinks.
	BacklinkClass []byte

	// BacklinkHTML is an HTML content for footnote backlinks.
	BacklinkHTML []byte
}

FootnoteConfig holds configuration values for the footnote extension.

Link* and Backlink* configurations have some variables: Occurrences of “^^” in the string will be replaced by the corresponding footnote number in the HTML output. Occurrences of “%%” will be replaced by a number for the reference (footnotes can have multiple references).

func NewFootnoteConfig added in v1.3.0

func NewFootnoteConfig() FootnoteConfig

NewFootnoteConfig returns a new Config with defaults.

func (*FootnoteConfig) SetOption added in v1.3.0

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

SetOption implements renderer.SetOptioner.

type FootnoteHTMLRenderer

type FootnoteHTMLRenderer struct {
	FootnoteConfig
}

FootnoteHTMLRenderer is a renderer.NodeRenderer implementation that renders FootnoteLink nodes.

func (*FootnoteHTMLRenderer) RegisterFuncs

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type FootnoteOption added in v1.3.0

type FootnoteOption interface {
	renderer.Option
	// SetFootnoteOption sets given option to the extension.
	SetFootnoteOption(*FootnoteConfig)
}

FootnoteOption interface is a functional option interface for the extension.

func WithFootnoteBacklinkClass added in v1.3.0

func WithFootnoteBacklinkClass[T []byte | string](a T) FootnoteOption

WithFootnoteBacklinkClass is a functional option that is a class for footnote backlinks.

func WithFootnoteBacklinkHTML added in v1.3.0

func WithFootnoteBacklinkHTML[T []byte | string](a T) FootnoteOption

WithFootnoteBacklinkHTML is an HTML content for footnote backlinks.

func WithFootnoteBacklinkTitle added in v1.3.0

func WithFootnoteBacklinkTitle[T []byte | string](a T) FootnoteOption

WithFootnoteBacklinkTitle is a functional option that is an optional title attribute for footnote backlinks.

func WithFootnoteHTMLOptions added in v1.3.0

func WithFootnoteHTMLOptions(opts ...html.Option) FootnoteOption

WithFootnoteHTMLOptions is functional option that wraps goldmark HTMLRenderer options.

func WithFootnoteIDPrefix added in v1.3.0

func WithFootnoteIDPrefix[T []byte | string](a T) FootnoteOption

WithFootnoteIDPrefix is a functional option that is a prefix for the id attributes generated by footnotes.

func WithFootnoteIDPrefixFunction added in v1.3.0

func WithFootnoteIDPrefixFunction(a func(gast.Node) []byte) FootnoteOption

WithFootnoteIDPrefixFunction is a functional option that is a prefix for the id attributes generated by footnotes.

func WithFootnoteLinkClass added in v1.3.0

func WithFootnoteLinkClass[T []byte | string](a T) FootnoteOption

WithFootnoteLinkClass is a functional option that is a class for footnote links.

func WithFootnoteLinkTitle added in v1.3.0

func WithFootnoteLinkTitle[T []byte | string](a T) FootnoteOption

WithFootnoteLinkTitle is a functional option that is an optional title attribute for footnote links.

type LinkifyConfig added in v1.1.20

type LinkifyConfig struct {
	AllowedProtocols [][]byte
	URLRegexp        *regexp.Regexp
	WWWRegexp        *regexp.Regexp
	EmailRegexp      *regexp.Regexp
}

An LinkifyConfig struct is a data structure that holds configuration of the Linkify extension.

func (*LinkifyConfig) SetOption added in v1.1.20

func (c *LinkifyConfig) SetOption(name parser.OptionName, value interface{})

SetOption implements SetOptioner.

type LinkifyOption added in v1.1.20

type LinkifyOption interface {
	parser.Option
	SetLinkifyOption(*LinkifyConfig)
}

A LinkifyOption interface sets options for the LinkifyOption.

func WithLinkifyAllowedProtocols added in v1.1.20

func WithLinkifyAllowedProtocols[T []byte | string](value []T) LinkifyOption

WithLinkifyAllowedProtocols is a functional option that specify allowed protocols in autolinks. Each protocol must end with ':' like 'http:' .

func WithLinkifyEmailRegexp added in v1.1.20

func WithLinkifyEmailRegexp(value *regexp.Regexp) LinkifyOption

WithLinkifyEmailRegexp is a functional otpion that specify a pattern of the email address.

func WithLinkifyURLRegexp added in v1.1.20

func WithLinkifyURLRegexp(value *regexp.Regexp) LinkifyOption

WithLinkifyURLRegexp is a functional option that specify a pattern of the URL including a protocol.

func WithLinkifyWWWRegexp added in v1.1.20

func WithLinkifyWWWRegexp(value *regexp.Regexp) LinkifyOption

WithLinkifyWWWRegexp is a functional option that specify a pattern of the URL without a protocol. This pattern must start with 'www.' .

type StrikethroughHTMLRenderer

type StrikethroughHTMLRenderer struct {
	html.Config
}

StrikethroughHTMLRenderer is a renderer.NodeRenderer implementation that renders Strikethrough nodes.

func (*StrikethroughHTMLRenderer) RegisterFuncs

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type TableCellAlignMethod added in v1.2.0

type TableCellAlignMethod int

TableCellAlignMethod indicates how are table cells aligned in HTML format.

const (
	// TableCellAlignDefault renders alignments by default method.
	// With XHTML, alignments are rendered as an align attribute.
	// With HTML5, alignments are rendered as a style attribute.
	TableCellAlignDefault TableCellAlignMethod = iota

	// TableCellAlignAttribute renders alignments as an align attribute.
	TableCellAlignAttribute

	// TableCellAlignStyle renders alignments as a style attribute.
	TableCellAlignStyle

	// TableCellAlignNone does not care about alignments.
	// If you using classes or other styles, you can add these attributes
	// in an ASTTransformer.
	TableCellAlignNone
)

type TableConfig added in v1.2.0

type TableConfig struct {
	html.Config

	// TableCellAlignMethod indicates how are table celss aligned.
	TableCellAlignMethod TableCellAlignMethod
}

TableConfig struct holds options for the extension.

func NewTableConfig added in v1.2.0

func NewTableConfig() TableConfig

NewTableConfig returns a new Config with defaults.

func (*TableConfig) SetOption added in v1.2.0

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

SetOption implements renderer.SetOptioner.

type TableHTMLRenderer

type TableHTMLRenderer struct {
	TableConfig
}

TableHTMLRenderer is a renderer.NodeRenderer implementation that renders Table nodes.

func (*TableHTMLRenderer) RegisterFuncs

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type TableOption added in v1.2.0

type TableOption interface {
	renderer.Option
	// SetTableOption sets given option to the extension.
	SetTableOption(*TableConfig)
}

TableOption interface is a functional option interface for the extension.

func WithTableCellAlignMethod added in v1.2.0

func WithTableCellAlignMethod(a TableCellAlignMethod) TableOption

WithTableCellAlignMethod is a functional option that indicates how are table cells aligned in HTML format.

func WithTableHTMLOptions added in v1.2.0

func WithTableHTMLOptions(opts ...html.Option) TableOption

WithTableHTMLOptions is functional option that wraps goldmark HTMLRenderer options.

type TaskCheckBoxHTMLRenderer

type TaskCheckBoxHTMLRenderer struct {
	html.Config
}

TaskCheckBoxHTMLRenderer is a renderer.NodeRenderer implementation that renders checkboxes in list items.

func (*TaskCheckBoxHTMLRenderer) RegisterFuncs

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type TypographerConfig

type TypographerConfig struct {
	Substitutions [][]byte
}

An TypographerConfig struct is a data structure that holds configuration of the Typographer extension.

func (*TypographerConfig) SetOption

func (b *TypographerConfig) SetOption(name parser.OptionName, value interface{})

SetOption implements SetOptioner.

type TypographerOption

type TypographerOption interface {
	parser.Option
	SetTypographerOption(*TypographerConfig)
}

A TypographerOption interface sets options for the TypographerParser.

func WithTypographicSubstitutions

func WithTypographicSubstitutions[T []byte | string](values map[TypographicPunctuation]T) TypographerOption

WithTypographicSubstitutions is a functional otpion that specify replacement text for punctuations.

type TypographicPunctuation

type TypographicPunctuation int

TypographicPunctuation is a key of the punctuations that can be replaced with typographic entities.

const (
	// LeftSingleQuote is ' .
	LeftSingleQuote TypographicPunctuation = iota + 1
	// RightSingleQuote is ' .
	RightSingleQuote
	// LeftDoubleQuote is " .
	LeftDoubleQuote
	// RightDoubleQuote is " .
	RightDoubleQuote
	// EnDash is -- .
	EnDash
	// EmDash is --- .
	EmDash
	// Ellipsis is ... .
	Ellipsis
	// LeftAngleQuote is << .
	LeftAngleQuote
	// RightAngleQuote is >> .
	RightAngleQuote
	// Apostrophe is ' .
	Apostrophe
)

type TypographicSubstitutions

type TypographicSubstitutions map[TypographicPunctuation][]byte

TypographicSubstitutions is a list of the substitutions for the Typographer extension.

Directories

Path Synopsis
Package ast defines AST nodes that represents extension's elements
Package ast defines AST nodes that represents extension's elements

Jump to

Keyboard shortcuts

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