Class: Presently::Slide::Fragment
- Inherits:
-
Object
- Object
- Presently::Slide::Fragment
- Defined in:
- lib/presently/slide.rb
Overview
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.
Constant Summary collapse
- EXTENSIONS =
Markly extensions enabled for all slide Markdown rendering.
[:table, :tasklist, :strikethrough, :autolink]
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
- #The underlying AST document node.(underlyingASTdocumentnode.) ⇒ Object readonly
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether the fragment has no content.
-
#initialize(node) ⇒ Fragment
constructor
Initialize a fragment from a Markly document node.
-
#to_commonmark ⇒ Object
(also: #to_s)
Render the fragment back to CommonMark Markdown.
-
#to_html ⇒ Object
Render the fragment to HTML using the Presently renderer.
Constructor Details
#initialize(node) ⇒ Fragment
Initialize a fragment from a Markly document node.
28 29 30 |
# File 'lib/presently/slide.rb', line 28 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
33 34 35 |
# File 'lib/presently/slide.rb', line 33 def node @node end |
#The underlying AST document node.(underlyingASTdocumentnode.) ⇒ Object (readonly)
33 |
# File 'lib/presently/slide.rb', line 33 attr :node |
Instance Method Details
#empty? ⇒ Boolean
Whether the fragment has no content.
37 38 39 |
# File 'lib/presently/slide.rb', line 37 def empty? @node.first_child.nil? end |
#to_commonmark ⇒ Object Also known as: to_s
Render the fragment back to CommonMark Markdown.
51 52 53 |
# File 'lib/presently/slide.rb', line 51 def to_commonmark @node.to_commonmark end |
#to_html ⇒ Object
Render the fragment to HTML using the Presently renderer.
Mermaid fenced code blocks are rendered as ‘<mermaid-diagram>` elements.
45 46 47 |
# File 'lib/presently/slide.rb', line 45 def to_html Renderer.new(flags: Markly::UNSAFE, extensions: EXTENSIONS).render(@node) end |