aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgKit/Models/NorgDocument.swift
blob: 73a3ed6b265373d91449b655b0c2f203eaef70c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// A fully parsed Norg document.
public struct NorgDocument: Equatable, Hashable, Sendable, Codable {

  /// The parsed blocks, as a flat list.
  public var blocks: [NorgBlock]

  /// Given an array of parsed blocks, create a document.
  public init(blocks: [NorgBlock] = []) {
    self.blocks = blocks
  }

  /// Converts the flat document into a tree.
  public func tree() -> [NorgNode] {
    TreeFolder(blocks).fold()
  }
}