package parser
Import Path
github.com/gomarkdown/markdown/parser (on go.dev)
Dependency Relation
imports 11 packages, and imported by 3 packages
Involved Source Files
aside.go
attribute.go
block.go
block_table.go
callout.go
caption.go
citation.go
esc.go
figures.go
include.go
inline.go
matter.go
options.go
Package parser implements parser for markdown text that generates AST (abstract syntax tree).
ref.go
Package-Level Type Names (total 9)
BlockFunc allows to registration of a parser function. If successful it
returns an ast.Node, a buffer that should be parsed as a block and the the number of bytes consumed.
Extensions is a bitmask of enabled parser extensions.
func NewWithExtensions(extension Extensions) *Parser
const Attributes
const AutoHeadingIDs
const Autolink
const BackslashLineBreak
const CommonExtensions
const DefinitionLists
const EmptyLinesBreakList
const FencedCode
const Footnotes
const HardLineBreak
const HeadingIDs
const Includes
const LaxHTMLBlocks
const MathJax
const Mmark
const NoEmptyLineBeforeBlock
const NoExtensions
const NoIntraEmphasis
const NonBlockingSpace
const OrderedListStart
const SpaceHeadings
const Strikethrough
const SuperSubscript
const Tables
const TabSizeEight
const Titleblock
Flags control optional behavior of parser.
const FlagsNone
const SkipFootnoteList
for each character that triggers a response when parsing inline data.
func (*Parser).RegisterInline(n byte, fn InlineParser) InlineParser
func (*Parser).RegisterInline(n byte, fn InlineParser) InlineParser
Options is a collection of supplementary parameters tweaking the behavior of various parts of the parser.
// Flags allow customizing parser's behavior
ParserHook BlockFunc
ReadIncludeFn ReadIncludeFunc
Parser is a type that holds extensions and the runtime state used by
Parse, and the renderer. You can not use it directly, construct it with New.
after parsing, this is AST root of parsed markdown text
InsideLink bool
IsSafeURLOverride allows overriding the default URL matcher. URL is
safe if the overriding function returns true. Can be used to extend
the default list of safe URLs.
Opts Options
ReferenceOverride is an optional function callback that is called every
time a reference is resolved. It can be set before starting parsing.
In Markdown, the link reference syntax can be made to resolve a link to
a reference instead of an inline URL, in one of the following ways:
* [link text][refid]
* [refid][]
Usually, the refid is defined at the bottom of the Markdown document. If
this override function is provided, the refid is passed to the override
function first, before consulting the defined refids at the bottom. If
the override function indicates an override did not occur, the refids at
the bottom will be used to fill in the link details.
(*Parser) AddBlock(n ast.Node) ast.Node
Parse Block-level data.
Note: this function and many that it calls assume that
the input buffer ends with a newline.
(*Parser) Finalize(block ast.Node)
Inline parses text within a block.
Each function returns the number of consumed chars.
Parse generates AST (abstract syntax tree) representing markdown document.
The result is a root of the tree whose underlying type is *ast.Document
You can then convert AST to html using html.Renderer, to some other format
using a custom renderer or transform the tree.
Parser is not reusable. Create a new Parser for each Parse() call.
(*Parser) RegisterInline(n byte, fn InlineParser) InlineParser
func New() *Parser
func NewWithExtensions(extension Extensions) *Parser
func github.com/gomarkdown/markdown.Parse(markdown []byte, p *Parser) ast.Node
func github.com/gomarkdown/markdown.ToHTML(markdown []byte, p *Parser, renderer markdown.Renderer) []byte
ReadIncludeFunc should read the file under path and returns the read bytes,
from will be set to the name of the current file being parsed. Initially
this will be empty. address is the optional address specifier of which lines
of the file to return. If this function is not set no data will be read.
Reference represents the details of a link.
See the documentation in Options for more details on use-case.
Link is usually the URL the reference points to.
Text is the optional text to override the ref with if the syntax used was
[refid][]
Title is the alternate text describing the link in more detail.
ReferenceOverrideFunc is expected to be called with a reference string and
return either a valid Reference type that the reference string maps to or
nil. If overridden is false, the default reference logic will be executed.
See the documentation in Options for more details on use-case.
Package-Level Functions (total 12)
IsAlnum returns true if c is a digit or letter
TODO: check when this is looking for ASCII alnum and when it should use unicode
IsCallout detects a callout in the following format: <<N>> Where N is a integer > 0.
IsLetter returns true if c is ascii letter
IsPunctuation returns true if c is a punctuation symbol.
func IsPunctuation2(d []byte) bool
IsSafeURL returns true if url starts with one of the valid schemes or is a relative path.
IsSpace returns true if c is a white-space character
LinesUntilEmpty scans lines up to the first empty line.
New creates a markdown parser with CommonExtensions.
You can then call `doc := p.Parse(markdown)` to parse markdown document
and `markdown.Render(doc, renderer)` to convert it to another format with
a renderer.
NewWithExtensions creates a markdown parser with given extensions.
func NormalizeNewlines(d []byte) []byte
Package-Level Constants (total 28)
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Parser renderer configuration options.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Parser renderer configuration options.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
Bit flags representing markdown parsing extensions.
Use | (or) to specify multiple extensions.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |