import Splash struct PageCodeProcessor { private let codeHighlightFooter = "" private let swift = SyntaxHighlighter(format: HTMLOutputFormat()) let results: PageGenerationResults init(results: PageGenerationResults) { self.results = results } func process(_ html: String, markdown: Substring) -> String { guard markdown.starts(with: "```swift") else { results.require(header: .codeHightlighting) results.require(footer: codeHighlightFooter) return html // Just use normal code highlighting } // Highlight swift code using Splash let code = markdown.between("```swift", and: "```").trimmed return "
" + swift.highlight(code) + "
" } }