parser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parser provides markdown file parsing and section extraction functionality. It extracts H2 sections from markdown files, parses timing annotations, and discovers markdown files in directory trees.

Key features:

  • H2 section extraction from markdown files
  • Timing annotation parsing (e.g., "## Scene 1 (5s)")
  • Recursive markdown file discovery
  • Input validation (file size, path safety)
  • Directory structure mirroring for batch processing

Index

Constants

View Source
const (
	// MaxFileSize is the maximum allowed markdown file size (10MB)
	MaxFileSize = 10 * 1024 * 1024 // 10MB should be more than enough for any reasonable markdown
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MarkdownFile

type MarkdownFile struct {
	AbsPath  string // Absolute path to the file
	RelPath  string // Relative path from base directory
	BaseDir  string // Base directory that was scanned
	FileName string // Just the filename without extension
}

MarkdownFile represents a discovered markdown file with its relative path

func FindMarkdownFiles

func FindMarkdownFiles(baseDir string) ([]MarkdownFile, error)

FindMarkdownFiles recursively finds all .md files in the given directory

func (MarkdownFile) GetOutputDir

func (mf MarkdownFile) GetOutputDir(baseOutputDir string) string

GetOutputDir returns the output directory path for this markdown file It creates a mirror structure based on the relative path

type Section

type Section struct {
	Title     string
	Content   string
	Duration  float64 // Target duration in seconds
	HasTiming bool    // Whether timing was specified
}

Section represents a markdown section with title and content

func ParseMarkdownFile

func ParseMarkdownFile(filename string) ([]Section, error)

ParseMarkdownFile parses a markdown file and extracts H2 sections

Jump to

Keyboard shortcuts

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