An Attributes is a collection of attributes.
Find returns a (value, true) if an attribute correspond with given name is found, otherwise (nil, false).
( T) findUpdate(name []byte, cb func(v interface{}) interface{}) bool
func ParseAttributes(reader text.Reader) (Attributes, bool)
A BlockParser interface parses a block level element like Paragraph, List,
Blockquote etc.
CanAcceptIndentedLine returns true if the parser can open new node when
the given line is being indented more than 3 spaces.
CanInterruptParagraph returns true if the parser can interrupt paragraphs,
otherwise false.
Close will be called when the parser returns Close.
Continue parses the current line and returns a result of parsing.
Continue must not parse beyond the current line.
If Continue has been able to parse the current line, Continue must advance
a reader position by consumed byte length.
If Continue has not been able to parse the current line, Continue should
returns Close. If Continue has been able to parse the current line,
Continue should returns (Continue | NoChildren) or
(Continue | HasChildren)
Open parses the current line and returns a result of parsing.
Open must not parse beyond the current line.
If Open has been able to parse the current line, Open must advance a reader
position by consumed byte length.
If Open has not been able to parse the current line, Open should returns
(nil, NoChildren). If Open has been able to parse the current line, Open
should returns a new Block node and returns HasChildren or NoChildren.
Trigger returns a list of characters that triggers Parse method of
this parser.
If Trigger returns a nil, Open will be called with any lines.
*atxHeadingParser
*blockquoteParser
*codeBlockParser
*fencedCodeBlockParser
*htmlBlockParser
*listItemParser
*listParser
*paragraphParser
*setextHeadingParser
*thematicBreakPraser
*github.com/yuin/goldmark/extension.definitionDescriptionParser
*github.com/yuin/goldmark/extension.definitionListParser
*github.com/yuin/goldmark/extension.footnoteBlockParser
func NewATXHeadingParser(opts ...HeadingOption) BlockParser
func NewBlockquoteParser() BlockParser
func NewCodeBlockParser() BlockParser
func NewFencedCodeBlockParser() BlockParser
func NewHTMLBlockParser() BlockParser
func NewListItemParser() BlockParser
func NewListParser() BlockParser
func NewParagraphParser() BlockParser
func NewSetextHeadingParser(opts ...HeadingOption) BlockParser
func NewThematicBreakParser() BlockParser
func github.com/yuin/goldmark/extension.NewDefinitionDescriptionParser() BlockParser
func github.com/yuin/goldmark/extension.NewDefinitionListParser() BlockParser
func github.com/yuin/goldmark/extension.NewFootnoteBlockParser() BlockParser
A CloseBlocker interface is a callback function that will be
called when block is closed in the inline parsing.
CloseBlock will be called when a block is closed.
*linkParser
A Context interface holds a information that are necessary to parse
Markdown text.
AddReference adds the given reference to this context.
BlockIndent returns an indent width on current line.
This value is valid only for BlockParser.Open.
BlockIndent returns -1 if current line is blank.
BlockOffset returns a first non-space character position on current line.
This value is valid only for BlockParser.Open.
BlockOffset returns -1 if current line is blank.
ClearDelimiters clears the current delimiter list.
ComputeIfAbsent computes a value if a value associated with the given key is absent and returns the value.
FirstDelimiter returns a first delimiter of the current delimiter list.
Get returns a value associated with the given key.
IDs returns a collection of the element ids.
IsInLinkLabel returns true if current position seems to be in link label.
LastDelimiter returns a last delimiter of the current delimiter list.
LastOpenedBlock returns a last node that is currently in parsing.
OpenedBlocks returns a list of nodes that are currently in parsing.
PushDelimiter appends the given delimiter to the tail of the current
delimiter list.
Reference returns (a reference, true) if a reference associated with
the given label exists, otherwise (nil, false).
References returns a list of references.
RemoveDelimiter removes the given delimiter from the current delimiter list.
Set sets the given value to the context.
BlockIndent sets an indent width on current line.
This value is valid only for BlockParser.Open.
BlockOffset sets a first non-space character position on current line.
This value is valid only for BlockParser.Open.
SetOpenedBlocks sets a list of nodes that are currently in parsing.
String implements Stringer.
*parseContext
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func NewContext(options ...ContextOption) Context
func ProcessDelimiters(bottom ast.Node, pc Context)
func WithContext(context Context) ParseOption
func ASTTransformer.Transform(node *ast.Document, reader text.Reader, pc Context)
func BlockParser.Close(node ast.Node, reader text.Reader, pc Context)
func BlockParser.Continue(node ast.Node, reader text.Reader, pc Context) State
func BlockParser.Open(parent ast.Node, reader text.Reader, pc Context) (ast.Node, State)
func CloseBlocker.CloseBlock(parent ast.Node, block text.Reader, pc Context)
func InlineParser.Parse(parent ast.Node, block text.Reader, pc Context) ast.Node
func ParagraphTransformer.Transform(node *ast.Paragraph, reader text.Reader, pc Context)
func golang.org/x/pkgsite/internal/postgres.(*ASTTransformer).Transform(node *ast.Document, reader text.Reader, pc Context)
func generateAutoHeadingID(node *ast.Heading, reader text.Reader, pc Context)
func parseLastLineAttributes(node ast.Node, reader text.Reader, pc Context)
func parseLinkReferenceDefinition(block text.Reader, pc Context) (int, int)
func processLinkLabelOpen(block text.Reader, pos int, isImage bool, pc Context) *linkLabelState
func pushLinkLabelState(pc Context, v *linkLabelState)
func removeLinkLabelState(pc Context, d *linkLabelState)
func github.com/yuin/goldmark/extension.getUnclosedCounter(pc Context) *extension.unclosedCounter
A ContextConfig struct is a data structure that holds configuration of the Context.
IDsIDs
An ContextOption is a functional option type for the Context.
func WithIDs(ids IDs) ContextOption
func NewContext(options ...ContextOption) Context
A Delimiter struct represents a delimiter like '*' of the Markdown text.
BaseInlineast.BaseInlineBaseInline.BaseNodeast.BaseNode
CanClose is set true if this delimiter can close a span for a new node.
See https://spec.commonmark.org/0.29/#can-open-emphasis for details.
CanOpen is set true if this delimiter can open a span for a new node.
See https://spec.commonmark.org/0.29/#can-open-emphasis for details.
Char is a character of this delimiter.
Length is a remaining length of this delimiter.
NextDelimiter is a next sibling delimiter node of this delimiter.
OriginalLength is a original length of this delimiter.
PreviousDelimiter is a previous sibling delimiter node of this delimiter.
Processor is a DelimiterProcessor associated with this delimiter.
Segmenttext.SegmentBaseInline.BaseNode.attributes[]ast.AttributeBaseInline.BaseNode.childCountintBaseInline.BaseNode.firstChildast.NodeBaseInline.BaseNode.lastChildast.NodeBaseInline.BaseNode.nextast.NodeBaseInline.BaseNode.parentast.NodeBaseInline.BaseNode.prevast.Node
AppendChild implements Node.AppendChild .
Attribute implements Node.Attribute.
AttributeString implements Node.AttributeString.
Attributes implements Node.Attributes
CalcComsumption calculates how many characters should be used for opening
a new span correspond to given closer.
ChildCount implements Node.ChildCount .
ConsumeCharacters consumes delimiters.
Dump implements Node.Dump.
FirstChild implements Node.FirstChild .
HasBlankPreviousLines implements Node.HasBlankPreviousLines.
HasChildren implements Node.HasChildren .
Inline implements Inline.Inline.
InsertAfter implements Node.InsertAfter .
InsertBefore implements Node.InsertBefore .
IsRaw implements Node.IsRaw
Kind implements Node.Kind
LastChild implements Node.LastChild .
Lines implements Node.Lines
NextSibling implements Node.NextSibling .
OwnerDocument implements Node.OwnerDocument
Parent implements Node.Parent .
PreviousSibling implements Node.PreviousSibling .
RemoveAttributes implements Node.RemoveAttributes
RemoveChild implements Node.RemoveChild .
RemoveChildren implements Node.RemoveChildren .
ReplaceChild implements Node.ReplaceChild .
SetAttribute implements Node.SetAttribute.
SetAttributeString implements Node.SetAttributeString
SetBlankPreviousLines implements Node.SetBlankPreviousLines.
SetLines implements Node.SetLines
SetNextSibling implements Node.SetNextSibling .
SetParent implements Node.SetParent .
SetPreviousSibling implements Node.SetPreviousSibling .
SortChildren implements Node.SortChildren
Text implements Node.Text
Type implements Node.Type
*T : github.com/yuin/goldmark/ast.Node
func NewDelimiter(canOpen, canClose bool, length int, char byte, processor DelimiterProcessor) *Delimiter
func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcessor) *Delimiter
func Context.FirstDelimiter() *Delimiter
func Context.LastDelimiter() *Delimiter
func Context.PushDelimiter(delimiter *Delimiter)
func Context.RemoveDelimiter(d *Delimiter)
func (*Delimiter).CalcComsumption(closer *Delimiter) int
func DelimiterProcessor.CanOpenCloser(opener, closer *Delimiter) bool
A DelimiterProcessor interface provides a set of functions about
Delimiter nodes.
CanOpenCloser returns true if given opener can close given closer, otherwise false.
IsDelimiter returns true if given character is a delimiter, otherwise false.
OnMatch will be called when new matched delimiter found.
OnMatch should return a new Node correspond to the matched delimiter.
*emphasisDelimiterProcessor
*github.com/yuin/goldmark/extension.strikethroughDelimiterProcessor
*github.com/yuin/goldmark/extension.typographerDelimiterProcessor
func NewDelimiter(canOpen, canClose bool, length int, char byte, processor DelimiterProcessor) *Delimiter
func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcessor) *Delimiter
An IDs interface is a collection of the element ids.
Generate generates a new element id.
Put puts a given element id to the used ids table.
*ids
*golang.org/x/pkgsite/internal/frontend.ids
func Context.IDs() IDs
func newIDs() IDs
func golang.org/x/pkgsite/internal/frontend.newIDs() IDs
func WithIDs(ids IDs) ContextOption
A ParagraphTransformer transforms parsed Paragraph nodes.
For example, link references are searched in parsed Paragraphs.
Transform transforms the given paragraph.
*linkReferenceParagraphTransformer
*github.com/yuin/goldmark/extension.tableParagraphTransformer
func github.com/yuin/goldmark/extension.NewTableParagraphTransformer() ParagraphTransformer
A ParseConfig struct is a data structure that holds configuration of the Parser.Parse.
ContextContext
A Parser interface parses Markdown text into AST nodes.
AddOption adds the given option to this parser.
Parse parses the given Markdown text into AST nodes.
*parser
func NewParser(options ...Option) Parser
func github.com/yuin/goldmark.DefaultParser() Parser
func github.com/yuin/goldmark.Markdown.Parser() Parser
func github.com/yuin/goldmark.WithParser(p Parser) goldmark.Option
func github.com/yuin/goldmark.Markdown.SetParser(Parser)
A Reference interface represents a link reference in Markdown text.
Destination returns a destination(URL) of the reference.
Label returns a label of the reference.
String implements Stringer.
Title returns a title of the reference.
*reference
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func NewReference(label, destination, title []byte) Reference
func Context.Reference(label string) (Reference, bool)
func Context.References() []Reference
func Context.AddReference(Reference)
A SetOptioner interface sets the given option to the object.
SetOption sets the given option to the object.
Unacceptable options may be passed.
Thus implementations must ignore unacceptable options.
*HeadingConfig
*github.com/yuin/goldmark/extension.LinkifyConfig
*github.com/yuin/goldmark/extension.TypographerConfig
*github.com/yuin/goldmark-emoji.ParserConfig
*atxHeadingParser
*setextHeadingParser
*github.com/yuin/goldmark/extension.linkifyParser
*github.com/yuin/goldmark/extension.typographerParser
*github.com/yuin/goldmark-emoji.emojiParser
Package-Level Functions (total 62, in which 37 are exported)
DefaultBlockParsers returns a new list of default BlockParsers.
Priorities of default BlockParsers are:
SetextHeadingParser, 100
ThematicBreakParser, 200
ListParser, 300
ListItemParser, 400
CodeBlockParser, 500
ATXHeadingParser, 600
FencedCodeBlockParser, 700
BlockquoteParser, 800
HTMLBlockParser, 900
ParagraphParser, 1000
DefaultInlineParsers returns a new list of default InlineParsers.
Priorities of default InlineParsers are:
CodeSpanParser, 100
LinkParser, 200
AutoLinkParser, 300
RawHTMLParser, 400
EmphasisParser, 500
DefaultParagraphTransformers returns a new list of default ParagraphTransformers.
Priorities of default ParagraphTransformers are:
LinkReferenceParagraphTransformer, 100
NewATXHeadingParser return a new BlockParser that can parse ATX headings.
NewAutoLinkParser returns a new InlineParser that parses autolinks
surrounded by '<' and '>' .
NewBlockquoteParser returns a new BlockParser that
parses blockquotes.
NewCodeBlockParser returns a new BlockParser that
parses code blocks.
NewCodeSpanParser return a new InlineParser that parses inline codes
surrounded by '`' .
NewConfig returns a new Config.
NewContext returns a new Context.
NewContextKey return a new ContextKey value.
NewDelimiter returns a new Delimiter node.
NewEmphasisParser return a new InlineParser that parses emphasises.
NewFencedCodeBlockParser returns a new BlockParser that
parses fenced code blocks.
NewHTMLBlockParser return a new BlockParser that can parse html
blocks.
NewLinkParser return a new InlineParser that parses links.
NewListItemParser returns a new BlockParser that
parses list items.
NewListParser returns a new BlockParser that
parses lists.
This parser must take precedence over the ListItemParser.
NewParagraphParser returns a new BlockParser that
parses paragraphs.
NewParser returns a new Parser with given options.
NewRawHTMLParser return a new InlineParser that can parse
inline htmls
NewReference returns a new Reference.
NewSetextHeadingParser return a new BlockParser that can parse Setext headings.
NewThematicBreakParser returns a new BlockParser that
parses thematic breaks.
ParseAttributes parses attributes into a map.
ParseAttributes returns a parsed attributes and true if could parse
attributes, otherwise nil and false.
ProcessDelimiters processes the delimiter list in the context.
Processing will be stop when reaching the bottom.
If you implement an inline parser that can have other inline nodes as
children, you should call this function when nesting span has closed.
ScanDelimiter scans a delimiter by given DelimiterProcessor.
WithASTTransformers is a functional option that allow you to add
ASTTransformers to the parser.
WithAttribute is a functional option that enables custom attributes.
WithAutoHeadingID is a functional option that enables custom heading ids and
auto generated heading ids.
WithBlockParsers is a functional option that allow you to add
BlockParsers to the parser.
WithContext is a functional option that allow you to override
a default context.
WithHeadingAttribute is a functional option that enables custom heading attributes.
WithIDs is a functional option for the Context.
WithInlineParsers is a functional option that allow you to add
InlineParsers to the parser.
WithOption is a functional option that allow you to set
an arbitrary option to the parser.
WithParagraphTransformers is a functional option that allow you to add
ParagraphTransformers to the parser.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.