...

Package extension

import "github.com/yuin/goldmark/extension"
Overview
Index
Subdirectories

Overview ▾

Index ▾

Variables
func NewCJK(opts ...CJKOption) goldmark.Extender
func NewDefinitionDescriptionParser() parser.BlockParser
func NewDefinitionListHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
func NewDefinitionListParser() parser.BlockParser
func NewFootnote(opts ...FootnoteOption) goldmark.Extender
func NewFootnoteASTTransformer() parser.ASTTransformer
func NewFootnoteBlockParser() parser.BlockParser
func NewFootnoteHTMLRenderer(opts ...FootnoteOption) renderer.NodeRenderer
func NewFootnoteParser() parser.InlineParser
func NewLinkify(opts ...LinkifyOption) goldmark.Extender
func NewLinkifyParser(opts ...LinkifyOption) parser.InlineParser
func NewStrikethroughHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
func NewStrikethroughParser() parser.InlineParser
func NewTable(opts ...TableOption) goldmark.Extender
func NewTableASTTransformer() parser.ASTTransformer
func NewTableHTMLRenderer(opts ...TableOption) renderer.NodeRenderer
func NewTableParagraphTransformer() parser.ParagraphTransformer
func NewTaskCheckBoxHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
func NewTaskCheckBoxParser() parser.InlineParser
func NewTypographer(opts ...TypographerOption) goldmark.Extender
func NewTypographerParser(opts ...TypographerOption) parser.InlineParser
type CJKOption
    func WithEastAsianLineBreaks() CJKOption
    func WithEscapedSpace() CJKOption
type DefinitionListHTMLRenderer
    func (r *DefinitionListHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type FootnoteConfig
    func NewFootnoteConfig() FootnoteConfig
    func (c *FootnoteConfig) SetOption(name renderer.OptionName, value interface{})
type FootnoteHTMLRenderer
    func (r *FootnoteHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type FootnoteOption
    func WithFootnoteBacklinkClass(a []byte) FootnoteOption
    func WithFootnoteBacklinkHTML(a []byte) FootnoteOption
    func WithFootnoteBacklinkTitle(a []byte) FootnoteOption
    func WithFootnoteHTMLOptions(opts ...html.Option) FootnoteOption
    func WithFootnoteIDPrefix(a []byte) FootnoteOption
    func WithFootnoteIDPrefixFunction(a func(gast.Node) []byte) FootnoteOption
    func WithFootnoteLinkClass(a []byte) FootnoteOption
    func WithFootnoteLinkTitle(a []byte) FootnoteOption
type LinkifyConfig
    func (c *LinkifyConfig) SetOption(name parser.OptionName, value interface{})
type LinkifyOption
    func WithLinkifyAllowedProtocols(value [][]byte) LinkifyOption
    func WithLinkifyEmailRegexp(value *regexp.Regexp) LinkifyOption
    func WithLinkifyURLRegexp(value *regexp.Regexp) LinkifyOption
    func WithLinkifyWWWRegexp(value *regexp.Regexp) LinkifyOption
type StrikethroughHTMLRenderer
    func (r *StrikethroughHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type TableCellAlignMethod
type TableConfig
    func NewTableConfig() TableConfig
    func (c *TableConfig) SetOption(name renderer.OptionName, value interface{})
type TableHTMLRenderer
    func (r *TableHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type TableOption
    func WithTableCellAlignMethod(a TableCellAlignMethod) TableOption
    func WithTableHTMLOptions(opts ...html.Option) TableOption
type TaskCheckBoxHTMLRenderer
    func (r *TaskCheckBoxHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type TypographerConfig
    func (b *TypographerConfig) SetOption(name parser.OptionName, value interface{})
type TypographerOption
    func WithTypographicSubstitutions(values map[TypographicPunctuation][]byte) TypographerOption
type TypographicPunctuation
type TypographicSubstitutions

Package files

cjk.go definition_list.go footnote.go gfm.go linkify.go strikethrough.go table.go tasklist.go typographer.go

Variables

var CJK = NewCJK(WithEastAsianLineBreaks(), WithEscapedSpace())

DefinitionDescriptionAttributeFilter defines attribute names which dd elements can have.

var DefinitionDescriptionAttributeFilter = html.GlobalAttributeFilter

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

var DefinitionList = &definitionList{}

DefinitionListAttributeFilter defines attribute names which dl elements can have.

var DefinitionListAttributeFilter = html.GlobalAttributeFilter

DefinitionTermAttributeFilter defines attribute names which dd elements can have.

var DefinitionTermAttributeFilter = html.GlobalAttributeFilter

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

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

GFM is an extension that provides Github Flavored markdown functionalities.

var GFM = &gfm{}

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

var Linkify = &linkify{}

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

var Strikethrough = &strikethrough{}

StrikethroughAttributeFilter defines attribute names which dd elements can have.

var StrikethroughAttributeFilter = html.GlobalAttributeFilter

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

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

TableAttributeFilter defines attribute names which table elements can have.

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

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

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

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

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

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

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"),
)

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

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"),
)

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

var TaskList = &taskList{}

Typographer is an extension that replaces punctuations with typographic entities.

var Typographer = &typographer{}

func NewCJK

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

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

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

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

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

NewTable returns a new extension with given options.

func NewTableASTTransformer

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.

type CJKOption

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

type CJKOption func(*cjk)

func WithEastAsianLineBreaks

func WithEastAsianLineBreaks() CJKOption

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

func WithEscapedSpace

func WithEscapedSpace() CJKOption

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

type DefinitionListHTMLRenderer

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

type DefinitionListHTMLRenderer struct {
    html.Config
}

func (*DefinitionListHTMLRenderer) RegisterFuncs

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

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type FootnoteConfig

FootnoteConfig holds configuration values for the footnote extension.

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

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
}

func NewFootnoteConfig

func NewFootnoteConfig() FootnoteConfig

NewFootnoteConfig returns a new Config with defaults.

func (*FootnoteConfig) SetOption

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

SetOption implements renderer.SetOptioner.

type FootnoteHTMLRenderer

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

type FootnoteHTMLRenderer struct {
    FootnoteConfig
}

func (*FootnoteHTMLRenderer) RegisterFuncs

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

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type FootnoteOption

FootnoteOption interface is a functional option interface for the extension.

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

func WithFootnoteBacklinkClass

func WithFootnoteBacklinkClass(a []byte) FootnoteOption

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

func WithFootnoteBacklinkHTML

func WithFootnoteBacklinkHTML(a []byte) FootnoteOption

WithFootnoteBacklinkHTML is an HTML content for footnote backlinks.

func WithFootnoteBacklinkTitle

func WithFootnoteBacklinkTitle(a []byte) FootnoteOption

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

func WithFootnoteHTMLOptions

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

WithFootnoteHTMLOptions is functional option that wraps goldmark HTMLRenderer options.

func WithFootnoteIDPrefix

func WithFootnoteIDPrefix(a []byte) FootnoteOption

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

func WithFootnoteIDPrefixFunction

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

func WithFootnoteLinkClass(a []byte) FootnoteOption

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

func WithFootnoteLinkTitle

func WithFootnoteLinkTitle(a []byte) FootnoteOption

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

type LinkifyConfig

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

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

func (*LinkifyConfig) SetOption

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

SetOption implements SetOptioner.

type LinkifyOption

A LinkifyOption interface sets options for the LinkifyOption.

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

func WithLinkifyAllowedProtocols

func WithLinkifyAllowedProtocols(value [][]byte) LinkifyOption

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

func WithLinkifyEmailRegexp

func WithLinkifyEmailRegexp(value *regexp.Regexp) LinkifyOption

func WithLinkifyURLRegexp

func WithLinkifyURLRegexp(value *regexp.Regexp) LinkifyOption

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

func WithLinkifyWWWRegexp

func WithLinkifyWWWRegexp(value *regexp.Regexp) LinkifyOption

type StrikethroughHTMLRenderer

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

type StrikethroughHTMLRenderer struct {
    html.Config
}

func (*StrikethroughHTMLRenderer) RegisterFuncs

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

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type TableCellAlignMethod

TableCellAlignMethod indicates how are table cells aligned in HTML format.indicates how are table cells aligned in HTML format.

type TableCellAlignMethod int
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

TableConfig struct holds options for the extension.

type TableConfig struct {
    html.Config

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

func NewTableConfig

func NewTableConfig() TableConfig

NewTableConfig returns a new Config with defaults.

func (*TableConfig) SetOption

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

SetOption implements renderer.SetOptioner.

type TableHTMLRenderer

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

type TableHTMLRenderer struct {
    TableConfig
}

func (*TableHTMLRenderer) RegisterFuncs

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

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type TableOption

TableOption interface is a functional option interface for the extension.

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

func WithTableCellAlignMethod

func WithTableCellAlignMethod(a TableCellAlignMethod) TableOption

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

func WithTableHTMLOptions

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

WithTableHTMLOptions is functional option that wraps goldmark HTMLRenderer options.

type TaskCheckBoxHTMLRenderer

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

type TaskCheckBoxHTMLRenderer struct {
    html.Config
}

func (*TaskCheckBoxHTMLRenderer) RegisterFuncs

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

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type TypographerConfig

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

type TypographerConfig struct {
    Substitutions [][]byte
}

func (*TypographerConfig) SetOption

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

SetOption implements SetOptioner.

type TypographerOption

A TypographerOption interface sets options for the TypographerParser.

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

func WithTypographicSubstitutions

func WithTypographicSubstitutions(values map[TypographicPunctuation][]byte) TypographerOption

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

type TypographicPunctuation

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

type TypographicPunctuation int
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

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

type TypographicSubstitutions map[TypographicPunctuation][]byte

Subdirectories

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