Allow whitespaces in svg size element

This commit is contained in:
Christoph Hagen 2022-09-04 17:48:13 +02:00
parent aa701d9793
commit a7e7bc21fc

View File

@ -75,8 +75,8 @@ struct PageContentGenerator {
// For images: ![left_title](file right_title) // For images: ![left_title](file right_title)
// For videos: ![option1,option2,...](file) // For videos: ![option1,option2,...](file)
// For svg with custom area: ![x,y,width,height](file.svg) // For svg with custom area: ![x,y,width,height](file.svg)
// For downloads: ![download](file1,text1;file2,text2, ...) // For downloads: ![download](file1, text1; file2, text2, ...)
// For files: ? // External pages: ![external](url1, text1; url2, text2, ...)
let fileAndTitle = markdown.between("(", and: ")") let fileAndTitle = markdown.between("(", and: ")")
let alt = markdown.between("[", and: "]").nonEmpty let alt = markdown.between("[", and: "]").nonEmpty
if alt == "download" { if alt == "download" {
@ -151,10 +151,10 @@ struct PageContentGenerator {
} }
let parts = area.components(separatedBy: ",").map { $0.trimmed } let parts = area.components(separatedBy: ",").map { $0.trimmed }
guard parts.count == 4, guard parts.count == 4,
let x = Int(parts[0]), let x = Int(parts[0].trimmed),
let y = Int(parts[1]), let y = Int(parts[1].trimmed),
let width = Int(parts[2]), let width = Int(parts[2].trimmed),
let height = Int(parts[3]) else { let height = Int(parts[3].trimmed) else {
log.add(warning: "Invalid area string for svg image", source: page.path) log.add(warning: "Invalid area string for svg image", source: page.path)
return factory.html.svgImage(file: file) return factory.html.svgImage(file: file)
} }