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