Documentation
¶
Overview ¶
Package converter provides functionality to convert Notion pages and blocks to Markdown format.
Index ¶
- func NormalizeID(id string) string
- func SanitizeFilename(name string) string
- type ConvertOptions
- type Converter
- func (c *Converter) Convert(page *notion.Page, blocks []notion.Block) []byte
- func (c *Converter) ConvertDatabase(database *notion.Database, dbPages []notion.DatabasePage, opts ConvertOptions) []byte
- func (c *Converter) ConvertWithOptions(page *notion.Page, blocks []notion.Block, opts ConvertOptions) []byte
- type FileProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeID ¶
NormalizeID removes dashes from Notion IDs for consistent format.
func SanitizeFilename ¶
SanitizeFilename makes a string safe for use as a filename. Only allows pattern [a-z][a-z0-9-]* (lowercase letters, numbers, hyphens). Must start with a letter.
Types ¶
type ConvertOptions ¶
type ConvertOptions struct {
Folder string // Folder name for this page
PageTitle string // Page title (used for child page link paths)
FilePath string // File path (stored in frontmatter)
LastSynced time.Time // When we synced this page
NotionType string // Type: "page" or "database"
IsRoot bool // Whether this is a root page
ParentID string // Resolved parent page/database ID (empty for root pages)
FileProcessor FileProcessor // Optional callback to process file URLs
}
ConvertOptions contains additional metadata for conversion.
type Converter ¶
type Converter struct {
// IncludeFrontmatter controls whether to include YAML frontmatter.
IncludeFrontmatter bool
}
Converter converts Notion pages and blocks to Markdown.
func NewConverter ¶
func NewConverter() *Converter
NewConverter creates a new converter with default settings.
func (*Converter) ConvertDatabase ¶
func (c *Converter) ConvertDatabase( database *notion.Database, dbPages []notion.DatabasePage, opts ConvertOptions, ) []byte
ConvertDatabase converts a database to Markdown with a list of direct child pages.
func (*Converter) ConvertWithOptions ¶
func (c *Converter) ConvertWithOptions(page *notion.Page, blocks []notion.Block, opts ConvertOptions) []byte
ConvertWithOptions converts a page and its blocks to Markdown with additional options.
type FileProcessor ¶
FileProcessor processes a file URL and returns the local path. If the file should be downloaded, it downloads it and returns the local path. If nil, files are not processed and URLs are used as-is.