Add more file properties, organize storage, add video block
This commit is contained in:
@ -8,7 +8,7 @@ struct MarkdownCodeProcessor: MarkdownProcessor {
|
||||
|
||||
private let blocks: [ContentBlock : BlockProcessor]
|
||||
|
||||
private let other: OtherCodeProcessor
|
||||
private let other: OtherCodeBlock
|
||||
|
||||
init(content: Content, results: PageGenerationResults, language: ContentLanguage) {
|
||||
self.results = results
|
||||
@ -23,10 +23,18 @@ struct MarkdownCodeProcessor: MarkdownProcessor {
|
||||
|
||||
func process(html: String, markdown: Substring) -> String {
|
||||
let input = String(markdown)
|
||||
let rawBlockId = input.dropAfterFirst("\n").dropBeforeFirst("```").trimmed
|
||||
let rawBlockId = input.dropAfterFirst("\n").dropBeforeFirst("```").trimmed.lowercased()
|
||||
guard let blockId = ContentBlock(rawValue: rawBlockId) else {
|
||||
guard knownCodeBlocks.contains(rawBlockId) else {
|
||||
results.invalid(block: nil, markdown)
|
||||
return ""
|
||||
}
|
||||
return other.process(html: html)
|
||||
}
|
||||
return blocks[blockId]!.process(markdown)
|
||||
}
|
||||
|
||||
private let knownCodeBlocks: Set<String> = [
|
||||
"bash", "nginx", "json", "css", "html", "markdown", ""
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user