md

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 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

This section is empty.

Types

type CodeBlock

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)
	Key    string `json:"key,omitempty"`    // opaque, stable identifier for the page; unique within the deck
}

Config represents the configuration for a slide.

type Content

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

Content represents a single slide content.

func ParseContent

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

type Contents []*Content

Contents represents a collection of slide contents.

type DefaultCondition

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

type Frontmatter struct {
	Title string `yaml:"title,omitempty" json:"title,omitempty"` // title of the presentation
	// Output is the path to the generated .pptx file.
	Output string `yaml:"output,omitempty" json:"output,omitempty"`
	// 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

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

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

Jump to

Keyboard shortcuts

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