PresentlySourcePresentlySlide

class Slide

A single slide parsed from a Markdown file.

Each slide has YAML front_matter for metadata (template, duration, focus), content sections split by Markdown headings, and optional presenter notes separated by ---.

Nested

Definitions

def self.load(path)

Load and parse a slide from a Markdown file.

Signature

parameter path String

The file path to the Markdown slide.

returns Slide

Implementation

def self.load(path)
	Parser.load(path)
end

def initialize(path, front_matter: nil, content: {}, notes: nil, script: nil)

Initialize a slide with pre-parsed data.

Signature

parameter path String

The file path of the slide.

parameter front_matter Hash | Nil

The parsed YAML front_matter.

parameter content Hash(String, Fragment)

Content sections keyed by heading name.

parameter notes Fragment | Nil

The presenter notes as a Markly AST fragment.

parameter script String | Nil

JavaScript to execute after the slide renders.

Implementation

def initialize(path, front_matter: nil, content: {}, notes: nil, script: nil)
	@path = path
	@front_matter = front_matter
	@content = content
	@notes = notes
	@script = script
end

attr :path

Signature

attribute String

The file path of the slide.

attr :front_matter

Signature

attribute Hash | Nil

The parsed YAML front_matter.

attr :content

Signature

attribute Hash(String, Fragment)

The content sections keyed by heading name.

attr :notes

Signature

attribute Fragment | Nil

The presenter notes as a Markly AST fragment.

attr :script

Signature

attribute String | Nil

JavaScript to execute after the slide renders on the display.

def template

The template to use for rendering this slide.

Signature

returns String

The template name from front_matter, or "default".

Implementation

def template
	@front_matter&.fetch("template", "default") || "default"
end

def duration

The expected duration of this slide in seconds.

Signature

returns Integer

The duration from front_matter, or 60.

Implementation

def duration
	@front_matter&.fetch("duration", 60) || 60
end

def title

The title of this slide.

Signature

returns String

The title from front_matter, or the filename without extension.

Implementation

def title
	@front_matter&.fetch("title", File.basename(@path, ".md")) || File.basename(@path, ".md")
end

def skip?

Whether this slide should be skipped in the presentation.

Signature

returns Boolean

Implementation

def skip?
	@front_matter&.fetch("skip", false) || false
end

def marker

The navigation marker for this slide, used in the presenter's jump-to dropdown.

Signature

returns String | Nil

The marker label, or nil if not marked.

Implementation

def marker
	@front_matter&.fetch("marker", nil)
end

def transition

The transition type for animating into this slide.

Signature

returns String | Nil

The transition name (e.g. "fade", "slide-left", "morph"), or nil for instant swap.

Implementation

def transition
	@front_matter&.fetch("transition", nil)
end

def speaker

The name of the speaker presenting this slide.

Signature

returns String | Nil

The speaker name from front_matter, or nil if not specified.

Implementation

def speaker
	@front_matter&.fetch("speaker", nil)
end

def focus

The line range to focus on for code slides.

Signature

returns Array(Integer, Integer) | Nil

The [start, end] line numbers (1-based), or nil.

Implementation

def focus
	if range = @front_matter&.fetch("focus", nil)
		parts = range.to_s.split("-").map(&:to_i)
		parts.length == 2 ? parts : nil
	end
end