Add builder pattern for paragraph, lists, tables

This commit is contained in:
2025-12-02 10:57:54 +01:00
parent 50c9c20eca
commit b602b2a2ff
25 changed files with 1248 additions and 47 deletions

View File

@@ -2,7 +2,9 @@
module Ezdoc
class Document
attr_reader :content
include Builder
attr_reader :nodes
def self.create(path, &block)
doc = new
@@ -12,15 +14,21 @@ module Ezdoc
end
def initialize
@content = []
end
def text(value)
@content << { text: value }
@nodes = []
@format_stack = []
@current_target = nil
@current_list = nil
@current_table = nil
@current_row = nil
@num_id_counter = 0
end
def save(path)
Package.new(self).save(path)
end
def lists
@nodes.select { |n| n.is_a?(Nodes::List) }
end
end
end