PresentlySourcePresentlySlideFragment

class Fragment

A fragment of a Markly AST document.

Wraps a Markly::Node of type :document and provides rendering helpers. Used for both content sections and presenter notes so callers can choose their output format without the parser pre-committing to one.

Definitions

EXTENSIONS = [:table, :tasklist, :strikethrough, :autolink]

Markly extensions enabled for all slide Markdown rendering.

def initialize(node)

Initialize a fragment from a Markly document node.

Signature

parameter node Markly::Node

A document node containing the fragment content.

Implementation

def initialize(node)
	@node = node
end

attr :node

Signature

attribute Markly::Node

The underlying AST document node.

def empty?

Whether the fragment has no content.

Signature

returns Boolean

Implementation

def empty?
	@node.first_child.nil?
end

def to_html

Render the fragment to HTML using the Presently renderer.

Mermaid fenced code blocks are rendered as <mermaid-diagram> elements.

Signature

returns String

The rendered HTML.

Implementation

def to_html
	Renderer.new(flags: Markly::UNSAFE, extensions: EXTENSIONS).render(@node)
end

def to_commonmark

Render the fragment back to CommonMark Markdown.

Signature

returns String

The CommonMark source.

Implementation

def to_commonmark
	@node.to_commonmark
end