krz/org-swift

A dependency-free Swift library that renders org-mode to sanitized HTML. html library org-mode swift

Sources/OrgSwift/Footnotes.swift

v0.4.0
org-swift/Sources/OrgSwift/Footnotes.swift history · blame · raw

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}