diff --git a/WebsiteGenerator/Generators/MarkdownProcessor.swift b/WebsiteGenerator/Generators/MarkdownProcessor.swift index 670ff66..1790e0a 100644 --- a/WebsiteGenerator/Generators/MarkdownProcessor.swift +++ b/WebsiteGenerator/Generators/MarkdownProcessor.swift @@ -4,6 +4,9 @@ import Splash struct PageContentGenerator { + #warning("Specify page image width in configuration") + let pageImageWidth = 748 + private let factory: TemplateFactory private let files: FileProcessor @@ -75,17 +78,16 @@ struct PageContentGenerator { case .video: return try handleVideo(page: page, file: file, optionString: alt) case .file: - #warning("Handle other files in markdown") - print("[WARN] Unhandled file \(file) with extension \(fileExtension)") - return "" + if fileExtension == "svg" { + return try handleSvg(page: page, file: file) + } + return try handleFile(page: page, file: file, fileExtension: fileExtension) } } private func handleImage(page: Page, file: String, rightTitle: String?, leftTitle: String?) throws -> String { let imagePath = page.pathRelativeToRootForContainedInputFile(file) - #warning("Specify page image width in configuration") - let pageImageWidth = 748 let size = try files.requireImage(source: imagePath, destination: imagePath, width: pageImageWidth) let imagePath2x = imagePath.insert("@2x", beforeLast: ".") @@ -122,4 +124,21 @@ struct PageContentGenerator { files.require(file: filePath) return factory.video.generate(sources: sources, options: options) } + + private func handleSvg(page: Page, file: String) throws -> String { + let imagePath = page.pathRelativeToRootForContainedInputFile(file) + files.require(file: imagePath) + + return """ + + + + """ + } + + private func handleFile(page: Page, file: String, fileExtension: String) throws -> String { + #warning("Handle other files in markdown") + print("[WARN] Unhandled file \(file) with extension \(fileExtension)") + return "" + } }