Fix icons, external file rename

This commit is contained in:
Christoph Hagen
2024-12-14 18:26:11 +01:00
parent be2aab2ea8
commit cdaaa36303
6 changed files with 22 additions and 44 deletions

View File

@@ -23,6 +23,7 @@ struct LabelsCommandProcessor: CommandProcessor {
results.invalid(command: .labels, markdown)
return nil
}
results.requiredIcons.insert(icon)
return .init(icon: icon, value: parts[1])
}
return ContentLabels(labels: labels).content

View File

@@ -1,32 +0,0 @@
import Ink
#warning("Remove if unused")
final class PageCommandExtractor {
private var occurrences: [(full: String, command: String, arguments: [String])] = []
func findOccurrences(of command: ShorthandMarkdownKey, in content: String) -> [(full: String, arguments: [String])] {
findOccurrences(of: command.rawValue, in: content)
}
func findOccurrences(of command: String, in content: String) -> [(full: String, arguments: [String])] {
let parser = MarkdownParser(modifiers: [
Modifier(target: .images, closure: processMarkdownImage),
])
_ = parser.html(from: content)
return occurrences
.filter { $0.command == command }
.map { ($0.full, $0.arguments) }
}
private func processMarkdownImage(html: String, markdown: Substring) -> String {
let argumentList = markdown.between(first: "](", andLast: ")").removingPercentEncoding ?? markdown.between(first: "](", andLast: ")")
let arguments = argumentList.components(separatedBy: ";")
let command = markdown.between("![", and: "]").trimmed
occurrences.append((full: String(markdown), command: command, arguments: arguments))
return ""
}
}