diff --git a/Sources/TreeConstructor/Document.swift b/Sources/TreeConstructor/Document.swift new file mode 100644 index 0000000..4759720 --- /dev/null +++ b/Sources/TreeConstructor/Document.swift @@ -0,0 +1,5 @@ +public struct Document: ~Copyable, Sendable { + public var title: String + public var body: Optional + public var head: Optional +} diff --git a/Sources/TreeConstructor/HTMLElement.swift b/Sources/TreeConstructor/HTMLElement.swift new file mode 100644 index 0000000..f488430 --- /dev/null +++ b/Sources/TreeConstructor/HTMLElement.swift @@ -0,0 +1,3 @@ +public struct HTMLElement: Sendable { + public var tagName: String +} diff --git a/Sources/TreeConstructor/Node.swift b/Sources/TreeConstructor/Node.swift new file mode 100644 index 0000000..453c559 --- /dev/null +++ b/Sources/TreeConstructor/Node.swift @@ -0,0 +1,9 @@ +public struct Node: Sendable { + public var value: NodeValue + public var childNodes: [Self] +} + +public enum NodeValue: Sendable { + case element(HTMLElement) + case text(Text) +} diff --git a/Sources/TreeConstructor/Text.swift b/Sources/TreeConstructor/Text.swift new file mode 100644 index 0000000..f98e1fc --- /dev/null +++ b/Sources/TreeConstructor/Text.swift @@ -0,0 +1,3 @@ +public struct Text: Sendable { + public var data: String +} diff --git a/Sources/TreeConstructor/TreeConstructor.swift b/Sources/TreeConstructor/TreeConstructor.swift index f09361d..28713c3 100644 --- a/Sources/TreeConstructor/TreeConstructor.swift +++ b/Sources/TreeConstructor/TreeConstructor.swift @@ -1,9 +1,11 @@ public import Tokenizer public struct TreeConstructor: ~Copyable { + public var document: Document private var mode: InsertionMode public init() { + self.document = .init(title: "", body: nil, head: nil) self.mode = .initial } }