markdown

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Overview

Package markdown owns Markdown parsing and rendering for presentation and generated-file boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeFrontmatter

func DecodeFrontmatter(source []byte, destination any) (body []byte, found bool, err error)

DecodeFrontmatter parses YAML frontmatter into destination and returns the authored Markdown body that follows it. Found is false when source has no frontmatter.

func DecodeFrontmatterReader

func DecodeFrontmatterReader(
	source io.Reader,
	destination any,
) (body io.Reader, found bool, err error)

DecodeFrontmatterReader parses YAML frontmatter from source and returns the remaining Markdown body without retaining that body in memory.

Body is nil when source has no frontmatter. DecodeFrontmatterReader does not close source. The source owner retains close ownership through body consumption.

func EncodeFrontmatter

func EncodeFrontmatter(metadata any, body []byte) ([]byte, error)

EncodeFrontmatter encodes metadata as YAML frontmatter followed by body.

func RewriteReferences

func RewriteReferences(
	source string,
	replace func(reference.Identity) string,
) string

RewriteReferences replaces parsed Cardamom references with caller-rendered Markdown while preserving references in escaped, code, and label contexts.

Types

type AttachmentResolver

type AttachmentResolver interface {
	// ResolveAttachments returns input-aligned attachment outcomes.
	ResolveAttachments(context.Context, attachment.ResolveRequest) ([]attachment.Resolution, error)
}

AttachmentResolver resolves one board-scoped attachment reference batch.

type IssueReferenceResolver

type IssueReferenceResolver interface {
	// ResolveIssueReferences returns issue IDs known to the board.
	ResolveIssueReferences(
		context.Context,
		board.ID,
		[]issue.ID,
	) ([]issue.ID, error)
}

IssueReferenceResolver resolves one board-scoped issue reference batch.

type LogReferenceResolver

type LogReferenceResolver interface {
	// ResolveLogReferences returns log ownership metadata known to the board.
	ResolveLogReferences(
		context.Context,
		board.ID,
		[]issue.LogID,
	) ([]issue.LogReference, error)
}

LogReferenceResolver resolves one board-scoped log reference batch.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer applies Cardamom's shared safe Markdown policy.

func New

func New() *Renderer

New constructs a Renderer with GFM, server-side code highlighting, Mermaid diagram markup, and Goldmark's safe HTML defaults. The browser owns diagram rendering and script loading.

func NewWithAttachments

func NewWithAttachments(attachments AttachmentResolver) *Renderer

NewWithAttachments constructs a Renderer that resolves attachment destinations in board-scoped batches.

func NewWithReferences

func NewWithReferences(
	attachments AttachmentResolver,
	issues IssueReferenceResolver,
	logs LogReferenceResolver,
) *Renderer

NewWithReferences constructs a Renderer that resolves attachment destinations and typed Cardamom references in board-scoped batches.

func (*Renderer) Render

func (r *Renderer) Render(source string) (string, error)

Render converts one Markdown source value to safe HTML.

func (*Renderer) RenderBoard

func (r *Renderer) RenderBoard(
	ctx context.Context,
	boardID board.ID,
	routePrefix string,
	sources []string,
) ([]string, error)

RenderBoard renders one response's Markdown sources after resolving unique typed references and attachment destinations in bounded board-scoped batches.

Directories

Path Synopsis
Package reference adds structured Cardamom references to Goldmark documents.
Package reference adds structured Cardamom references to Goldmark documents.

Jump to

Keyboard shortcuts

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