Class: Markbridge::AST::Document

Inherits:
Element show all
Defined in:
lib/markbridge/ast/document.rb

Overview

Represents the root document node of the AST. This is the top-level container that holds all other elements.

Examples:

Creating a document

doc = AST::Document.new
doc << AST::Text.new("Hello, world!")

Creating a document with initial children

doc = AST::Document.new([
  AST::Text.new("Hello"),
  AST::Bold.new
])

Instance Attribute Summary

Attributes inherited from Element

#children

Instance Method Summary collapse

Methods inherited from Element

#<<

Constructor Details

#initialize(children = []) ⇒ Document

Create a new document node.

Parameters:

  • children (Array<Node>) (defaults to: [])

    optional array of initial child nodes



21
22
23
24
# File 'lib/markbridge/ast/document.rb', line 21

def initialize(children = [])
  super()
  Array(children).each { |c| self << c }
end