Files
swift-hpa/Sources/CliDoc/Nodes/Section.swift

31 lines
729 B
Swift

public struct Section: NodeRepresentable {
@usableFromInline
let content: any NodeRepresentable
public init(@NodeBuilder content: () -> any NodeRepresentable) {
self.content = content()
}
public func render() -> String {
guard let many = content as? _ManyNode else {
return content.render() + "\n\n"
}
let node = _ManyNode(many.nodes, separator: "\n\n")
return node.render()
// var output = ""
// let lastIndex = many.nodes.count - 1
//
// for (idx, content) in many.nodes.enumerated() {
// if idx != lastIndex {
// output += content.render() + "\n\n"
// } else {
// output += content.render() + "\n"
// }
// }
// return output
}
}