mdutils

package
v0.0.0-...-7b96089 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplateHelpers = map[string]any{
	"json":         Json,
	"markdownTree": MarkdownTree,

	"renderMarkdown": func(level int, input any) string {
		return RenderWithContext(&RenderContext{HeadingLevel: level}, input)
	},
}

Functions

func FormatMarkdown

func FormatMarkdown(node ast.Node) []byte

func Json

func Json(input any) string

func MarkdownTree

func MarkdownTree(initialDepth int, input any) string

func ParseMarkdown

func ParseMarkdown(md []byte) ast.Node

func RegisterMarkdownHelpers

func RegisterMarkdownHelpers()

func RenderToNode

func RenderToNode(ctx *RenderContext, r any) ast.Node

func RenderWithContext

func RenderWithContext(ctx *RenderContext, r any) string

Types

type CodeBlock

type CodeBlock struct {
	Filename string `json:"filename" jsonschema:"title=Filename,description=Filename of the code block."`
	Language string `json:"language" jsonschema:"title=Language,description=Language of the code block."`
	Code     string `json:"code" jsonschema:"title=Code,description=Code of the code block."`
}

CodeBlock represents a block of code with its language and code content.

func ExtractCodeBlocks

func ExtractCodeBlocks(root ast.Node) (blocks []CodeBlock)

ExtractCodeBlocks traverses the given AST and extracts all code blocks. It returns a slice of CodeBlock objects, each representing a code block with its language and code content.

func (CodeBlock) Render

func (c CodeBlock) Render(ctx *RenderContext) ast.Node

type RenderContext

type RenderContext struct {
	HeadingLevel int
}

func (*RenderContext) SpawnHeading

func (ctx *RenderContext) SpawnHeading(title string) *ast.Heading

type Renderable

type Renderable interface {
	Render(ctx *RenderContext) ast.Node
}

type RenderableFunc

type RenderableFunc func() ast.Node

Jump to

Keyboard shortcuts

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