markdown

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package markdown is the markdown engine: parsing memo content into the AST in markdown/ast, the memos-specific syntax in markdown/extensions and markdown/parser (tags, mentions, math, GFM extras), rendering, and the derived memo payload (tags, properties, snippet).

Layering: markdown may import proto/gen and internal. It must not import store, core, or server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseManagedAttachmentImageURL

func ParseManagedAttachmentImageURL(raw string) (uid string, managed, valid bool)

ParseManagedAttachmentImageURL parses a same-origin relative managed image URL. Absolute URL origin matching is intentionally left to callers that know the configured instance URL.

Types

type ExtractedData

type ExtractedData struct {
	Tags                               []string
	Mentions                           []string
	ImageDestinations                  []string
	ManagedAttachmentReferences        []ManagedAttachmentReference
	InvalidManagedAttachmentReferences []string
	Property                           *storepb.MemoPayload_Property
}

ExtractedData contains all metadata extracted from markdown in a single pass.

type ManagedAttachmentReference

type ManagedAttachmentReference struct {
	UID string
}

ManagedAttachmentReference is an attachment URL embedded using Markdown image syntax.

type Option

type Option func(*config)

Option configures the markdown service.

func WithMentionExtension

func WithMentionExtension() Option

WithMentionExtension enables @mention parsing.

func WithTagExtension

func WithTagExtension() Option

WithTagExtension enables #tag parsing.

type Service

type Service interface {
	// ExtractAll extracts tags, properties, and references in a single parse (most efficient)
	ExtractAll(content []byte) (*ExtractedData, error)

	// ExtractTags returns all #tags found in content
	ExtractTags(content []byte) ([]string, error)

	// ExtractProperties computes boolean properties
	ExtractProperties(content []byte) (*storepb.MemoPayload_Property, error)

	// RenderMarkdown renders goldmark AST back to markdown text
	RenderMarkdown(content []byte) (string, error)

	// GenerateSnippet creates plain text summary
	GenerateSnippet(content []byte, maxLength int) (string, error)

	// ValidateContent checks for syntax errors
	ValidateContent(content []byte) error

	// RenameTag renames all occurrences of oldTag to newTag in content
	RenameTag(content []byte, oldTag, newTag string) (string, error)
}

Service handles markdown metadata extraction. It uses goldmark to parse markdown and extract tags, properties, and snippets.

func NewService

func NewService(opts ...Option) Service

NewService creates a new markdown service with the given options.

Directories

Path Synopsis
tagdata command
Command tagdata generates the fixed Unicode and emoji tables used by the Memos tag lexer.
Command tagdata generates the fixed Unicode and emoji tables used by the Memos tag lexer.

Jump to

Keyboard shortcuts

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