Syntax highlight swift code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import Ink
|
||||
import Splash
|
||||
|
||||
struct PageContentGenerator {
|
||||
|
||||
@@ -7,6 +8,8 @@ struct PageContentGenerator {
|
||||
|
||||
private let files: FileProcessor
|
||||
|
||||
private let swift = SyntaxHighlighter(format: HTMLOutputFormat())
|
||||
|
||||
init(factory: TemplateFactory, files: FileProcessor) {
|
||||
self.factory = factory
|
||||
self.files = files
|
||||
@@ -31,8 +34,8 @@ struct PageContentGenerator {
|
||||
}
|
||||
let codeModifier = Modifier(target: .codeBlocks) { html, markdown in
|
||||
if markdown.starts(with: "```swift") {
|
||||
#warning("Syntax highlight swift code")
|
||||
return html
|
||||
let code = markdown.between("```swift", and: "```").trimmed
|
||||
return "<pre><code>" + swift.highlight(code) + "</pre></code>"
|
||||
}
|
||||
hasCodeContent = true
|
||||
return html
|
||||
|
Reference in New Issue
Block a user