md

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package md provides functionality for parsing markdown into slides.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFrontmatterToMD added in v0.38.0

func ApplyFrontmatterToMD(mdFile, title, presentationID string) (err error)

ApplyFrontmatterToMD updates or creates a markdown file with frontmatter.

func DiffContents added in v0.15.0

func DiffContents(oldContents, newContents Contents) []int

DiffContents compares two Contents and returns the page numbers that have changed. Page numbers are 1-indexed.

Types

type CodeBlock added in v0.24.0

type CodeBlock struct {
	Language string `json:"language,omitempty"`
	Content  string `json:"content"`
}

type Config

type Config struct {
	Layout string `json:"layout,omitempty"` // layout name
	Freeze *bool  `json:"freeze,omitempty"` // freeze the page
	Ignore *bool  `json:"ignore,omitempty"` // ignore the page (skip slide generation)
	Skip   *bool  `json:"skip,omitempty"`   // skip the page (do not show in the presentation)
}

Config represents the configuration for a slide.

type Content added in v0.14.0

type Content struct {
	Layout         string             `json:"layout"`
	Freeze         *bool              `json:"freeze,omitempty"`
	Ignore         *bool              `json:"ignore,omitempty"`
	Skip           *bool              `json:"skip,omitempty"`
	Titles         []string           `json:"titles,omitempty"`
	TitleBodies    []*deck.Body       `json:"-"`
	Subtitles      []string           `json:"subtitles,omitempty"`
	SubtitleBodies []*deck.Body       `json:"-"`
	Bodies         []*deck.Body       `json:"bodies,omitempty"`
	Images         []*deck.Image      `json:"images,omitempty"`
	CodeBlocks     []*CodeBlock       `json:"code_blocks,omitempty"`
	BlockQuotes    []*deck.BlockQuote `json:"block_quotes,omitempty"`
	Tables         []*deck.Table      `json:"tables,omitempty"`
	Comments       []string           `json:"comments,omitempty"`
	Headings       map[int][]string   `json:"headings,omitempty"`
}

Content represents a single slide content.

func ParseContent added in v0.14.0

func ParseContent(baseDir string, b []byte, breaks bool) (_ *Content, err error)

ParseContent parses a single markdown content into a Content structure. It processes headings, lists, paragraphs, and HTML blocks to create a structured representation.

type Contents added in v0.14.0

type Contents []*Content

Contents represents a collection of slide contents.

type DefaultCondition added in v1.0.0

type DefaultCondition struct {
	If     string `json:"if"`               // condition to check
	Layout string `json:"layout,omitempty"` // layout name to apply if condition is true
	Freeze *bool  `json:"freeze,omitempty"` // freeze the page
	Ignore *bool  `json:"ignore,omitempty"` // whether to ignore the page if condition is true
	Skip   *bool  `json:"skip,omitempty"`   // whether to skip the page if condition is true
}

type Frontmatter added in v0.31.0

type Frontmatter struct {
	PresentationID string `yaml:"presentationID,omitempty" json:"presentationID,omitempty"` // ID of the Google Slides presentation
	Title          string `yaml:"title,omitempty" json:"title,omitempty"`                   // title of the presentation
	// Whether to display line breaks in the document as line breaks
	Breaks *bool `yaml:"breaks,omitempty" json:"breaks,omitempty"`
	// Conditions for default
	Defaults []DefaultCondition `yaml:"defaults,omitempty" json:"defaults,omitempty"`
	// command to convert code blocks to images
	CodeBlockToImageCommand string `yaml:"codeBlockToImageCommand,omitempty" json:"codeBlockToImageCommand,omitempty"`
}

Frontmatter represents YAML frontmatter data.

type MD added in v0.31.0

type MD struct {
	Frontmatter *Frontmatter
	Contents    Contents
}

MD represents a markdown presentation.

func Parse

func Parse(baseDir string, b []byte, cfg *config.Config) (_ *MD, err error)

Parse parses markdown bytes into contents. It splits the input by "---" delimiters and parses each section as a separate content.

func ParseFile

func ParseFile(f string, cfg *config.Config) (_ *MD, err error)

ParseFile parses a markdown file into contents.

func (*MD) ToSlides added in v1.0.0

func (md *MD) ToSlides(ctx context.Context, codeBlockToImageCmd string) (_ deck.Slides, err error)

Jump to

Keyboard shortcuts

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