Decode percent encodings for markdown images

This commit is contained in:
Christoph Hagen 2023-02-20 15:40:31 +01:00
parent 87d54788db
commit 6e717a8cf7

View File

@ -87,8 +87,11 @@ struct PageContentGenerator {
// For a simple boxes: ![box](title;body)
// A fancy page link: ![page](page_id)
// External pages: ![external](url1, text1; url2, text2, ...)
let fileAndTitle = markdown.between(first: "](", andLast: ")")
let alt = markdown.between("[", and: "]").nonEmpty
guard let fileAndTitle = markdown.between(first: "](", andLast: ")").removingPercentEncoding else {
results.warning("Invalid percent encoding for markdown image", source: page.path)
return ""
}
let alt = markdown.between("[", and: "]").nonEmpty?.removingPercentEncoding
if let alt = alt, let command = ShorthandMarkdownKey(rawValue: alt) {
return handleShortHandCommand(command, page: page, language: language, content: fileAndTitle)
}