
struct LabelsBlock: OrderedKeyBlockProcessor {

    typealias Key = PageIcon

    static let blockId: ContentBlock = .labels

    let content: Content

    let results: PageGenerationResults

    let language: ContentLanguage

    init(content: Content, results: PageGenerationResults, language: ContentLanguage) {
        self.content = content
        self.results = results
        self.language = language
    }

    func process(_ arguments: [(key: PageIcon, value: String)], markdown: Substring) -> String {
        let labels: [ContentLabel] = arguments.compactMap { (icon, value) in
            guard value != "" else {
                invalid(markdown)
                return nil
            }
            results.require(icon: icon)
            return .init(icon: icon, value: value)
        }
        return ContentLabels(labels: labels).content
    }
}
