Add more file properties, organize storage, add video block

This commit is contained in:
Christoph Hagen
2025-01-06 15:31:19 +01:00
parent 96c0a75c2f
commit 6cf310d849
25 changed files with 712 additions and 219 deletions

View File

@ -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", ""
]
}