import Foundation /// Detect a reference-style footnote definition line: `[fn:label] text…`. Returns the /// label and the definition text, or nil if the line is not one. func orgFootnoteDefinition(in line: String) -> (label: String, text: String)? { guard let match = line.firstMatch(of: /^\[fn:([A-Za-z0-9_-]+)\]\s+(.+)$/) else { return nil } return (String(match.1), String(match.2)) }