markdown

package
v1.14.5 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 28 Imported by: 227

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KindDetails = ast.NewNodeKind("Details")

KindDetails is the NodeKind for Details

View Source
var KindIcon = ast.NewNodeKind("Icon")

KindIcon is the NodeKind for Icon

View Source
var KindSummary = ast.NewNodeKind("Summary")

KindSummary is the NodeKind for Summary

View Source
var KindTaskCheckBoxListItem = ast.NewNodeKind("TaskCheckBoxListItem")

KindTaskCheckBoxListItem is the NodeKind for TaskCheckBoxListItem

View Source
var (
	// MarkupName describes markup's name
	MarkupName = "markdown"
)

Functions

func ExtractMetadata added in v1.13.0

func ExtractMetadata(contents string, out interface{}) (string, error)

ExtractMetadata consumes a markdown file, parses YAML frontmatter, and returns the frontmatter metadata separated from the markdown content

func IsDetails added in v1.12.0

func IsDetails(node ast.Node) bool

IsDetails returns true if the given node implements the Details interface, otherwise false.

func IsIcon added in v1.12.0

func IsIcon(node ast.Node) bool

IsIcon returns true if the given node implements the Icon interface, otherwise false.

func IsMarkdownFile

func IsMarkdownFile(name string) bool

IsMarkdownFile reports whether name looks like a Markdown file based on its extension.

func IsSummary added in v1.12.0

func IsSummary(node ast.Node) bool

IsSummary returns true if the given node implements the Summary interface, otherwise false.

func IsTaskCheckBoxListItem added in v1.12.0

func IsTaskCheckBoxListItem(node ast.Node) bool

IsTaskCheckBoxListItem returns true if the given node implements the TaskCheckBoxListItem interface, otherwise false.

func NewGiteaParseContext added in v1.11.0

func NewGiteaParseContext(urlPrefix string, metas map[string]string, isWiki bool) parser.Context

NewGiteaParseContext creates a parser.Context with the gitea context set

func NewHTMLRenderer added in v1.12.0

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

NewHTMLRenderer creates a HTMLRenderer to render in the gitea form.

func Render

func Render(rawBytes []byte, urlPrefix string, metas map[string]string) []byte

Render renders Markdown to HTML with all specific handling stuff.

func RenderRaw

func RenderRaw(body []byte, urlPrefix string, wikiMarkdown bool) []byte

RenderRaw renders Markdown to HTML without handling special links.

func RenderString

func RenderString(raw, urlPrefix string, metas map[string]string) string

RenderString renders Markdown to HTML with special links and returns string type.

func RenderWiki

func RenderWiki(rawBytes []byte, urlPrefix string, metas map[string]string) string

RenderWiki renders markdown wiki page to HTML and return HTML string

Types

type ASTTransformer added in v1.12.0

type ASTTransformer struct{}

ASTTransformer is a default transformer of the goldmark tree.

func (*ASTTransformer) Transform added in v1.12.0

func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context)

Transform transforms the given AST tree.

type Details added in v1.12.0

type Details struct {
	ast.BaseBlock
}

Details is a block that contains Summary and details

func NewDetails added in v1.12.0

func NewDetails() *Details

NewDetails returns a new Paragraph node.

func (*Details) Dump added in v1.12.0

func (n *Details) Dump(source []byte, level int)

Dump implements Node.Dump .

func (*Details) Kind added in v1.12.0

func (n *Details) Kind() ast.NodeKind

Kind implements Node.Kind.

type HTMLRenderer added in v1.12.0

type HTMLRenderer struct {
	html.Config
}

HTMLRenderer is a renderer.NodeRenderer implementation that renders gitea specific features.

func (*HTMLRenderer) RegisterFuncs added in v1.12.0

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

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.

type Header struct {
	Level int
	Text  string
	ID    string
}

Header holds the data about a header.

type Icon added in v1.12.0

type Icon struct {
	ast.BaseInline
	Name []byte
}

Icon is an inline for a fomantic icon

func NewIcon added in v1.12.0

func NewIcon(name string) *Icon

NewIcon returns a new Paragraph node.

func (*Icon) Dump added in v1.12.0

func (n *Icon) Dump(source []byte, level int)

Dump implements Node.Dump .

func (*Icon) Kind added in v1.12.0

func (n *Icon) Kind() ast.NodeKind

Kind implements Node.Kind.

type Parser

type Parser struct{}

Parser implements markup.Parser

func (Parser) Extensions

func (Parser) Extensions() []string

Extensions implements markup.Parser

func (Parser) Name

func (Parser) Name() string

Name implements markup.Parser

func (Parser) Render

func (Parser) Render(rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte

Render implements markup.Parser

type RenderConfig added in v1.12.0

type RenderConfig struct {
	Meta string
	Icon string
	TOC  bool
	Lang string
}

RenderConfig represents rendering configuration for this file

func (*RenderConfig) ToRenderConfig added in v1.12.0

func (rc *RenderConfig) ToRenderConfig(meta yaml.MapSlice)

ToRenderConfig converts a yaml.MapSlice to a RenderConfig

type Summary added in v1.12.0

type Summary struct {
	ast.BaseBlock
}

Summary is a block that contains the summary of details block

func NewSummary added in v1.12.0

func NewSummary() *Summary

NewSummary returns a new Summary node.

func (*Summary) Dump added in v1.12.0

func (n *Summary) Dump(source []byte, level int)

Dump implements Node.Dump .

func (*Summary) Kind added in v1.12.0

func (n *Summary) Kind() ast.NodeKind

Kind implements Node.Kind.

type TaskCheckBoxListItem added in v1.12.0

type TaskCheckBoxListItem struct {
	*ast.ListItem
	IsChecked bool
}

TaskCheckBoxListItem is a block that repressents a list item of a markdown block with a checkbox

func NewTaskCheckBoxListItem added in v1.12.0

func NewTaskCheckBoxListItem(listItem *ast.ListItem) *TaskCheckBoxListItem

NewTaskCheckBoxListItem returns a new TaskCheckBoxListItem node.

func (*TaskCheckBoxListItem) Dump added in v1.12.0

func (n *TaskCheckBoxListItem) Dump(source []byte, level int)

Dump implements Node.Dump .

func (*TaskCheckBoxListItem) Kind added in v1.12.0

func (n *TaskCheckBoxListItem) Kind() ast.NodeKind

Kind implements Node.Kind.

Jump to

Keyboard shortcuts

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