Add more file properties, organize storage, add video block
This commit is contained in:
26
CHDataManagement/Generator/Blocks/SwiftBlock.swift
Normal file
26
CHDataManagement/Generator/Blocks/SwiftBlock.swift
Normal file
@ -0,0 +1,26 @@
|
||||
import Splash
|
||||
|
||||
struct SwiftBlock: BlockProcessor {
|
||||
|
||||
static let blockId: ContentBlock = .swift
|
||||
|
||||
let content: Content
|
||||
|
||||
let results: PageGenerationResults
|
||||
|
||||
let language: ContentLanguage
|
||||
|
||||
private let swift = SyntaxHighlighter(format: HTMLOutputFormat())
|
||||
|
||||
init(content: Content, results: PageGenerationResults, language: ContentLanguage) {
|
||||
self.content = content
|
||||
self.results = results
|
||||
self.language = language
|
||||
}
|
||||
|
||||
func process(_ markdown: Substring) -> String {
|
||||
// Highlight swift code using Splash
|
||||
let code = markdown.between("```swift", and: "```").trimmed
|
||||
return "<pre><code>" + swift.highlight(code) + "</pre></code>"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user