import Foundation typealias SVGSelection = (x: Int, y: Int, width: Int, height: Int) struct HTMLElementsGenerator { func make(title: String, suffix: String) -> String { "\(title)\(suffix)" } func topBarWebsiteTitle(language: String, from page: Element) -> String { guard let pathToRoot = page.pathToRoot else { return Element.htmlPageName(for: language) } return pathToRoot + Element.htmlPagePathAddition(for: language) } func topBarLanguageButton(_ language: String) -> String { "\(language)" } func topBarNavigationLink(url: String, text: String, isActive: Bool) -> String { "\(text)" } func linkPreviewImage(file: String) -> String { "" } func makePrevText(_ text: String) -> String { "\(text)" } func makeNextText(_ text: String) -> String { "\(text)" } func image(file: String, width: Int, height: Int, altText: String) -> String { let ratio = Float(width) / Float(height) return """ \(altText) """ } func svgImage(file: String, part: SVGSelection, altText: String) -> String { let path = "\(file)#svgView(viewBox(\(part.x), \(part.y), \(part.width), \(part.height)))" return image(file: path, width: part.width, height: part.height, altText: altText) } func downloadButtons(_ buttons: [(file: String, text: String, downloadName: String?)]) -> String { let content = buttons.map { if let download = $0.downloadName { return button(file: $0.file, text: $0.text, downloadName: download) } else { return button(file: $0.file, text: $0.text) } }.joined(separator: "\n") return flexParagraph(content) } func externalButtons(_ buttons: [(url: String, text: String)]) -> String { let content = buttons .map { externalLink(url: $0.url, text: $0.text) } .joined(separator: "\n") return flexParagraph(content) } private func flexParagraph(_ content: String) -> String { """

\(content)

""" } private func button(file: String, text: String) -> String { """ \(text) """ } private func button(file: String, text: String, downloadName: String) -> String { """ \(text) """ } private func externalLink(url: String, text: String) -> String { """ \(text) """ } func scriptInclude(path: String, asModule: Bool) -> String { if asModule { return "" } return "" } func codeHighlightFooter() -> String { "" } }