2025-01-02 11:56:51 +01:00

25 lines
656 B
Swift

struct BoxCommandProcessor: CommandProcessor {
let commandType: ShorthandMarkdownKey = .box
let results: PageGenerationResults
init(content: Content, results: PageGenerationResults) {
self.results = results
}
/**
Format: `![box](<title>;<body>)`
*/
func process(_ arguments: [String], markdown: Substring) -> String {
guard arguments.count > 1 else {
results.invalid(command: .box, markdown)
return ""
}
let title = arguments[0]
let text = arguments.dropFirst().joined(separator: ";")
return ContentBox(title: title, text: text).content
}
}