import Foundation func orderedListItem(in line: String) -> String? { guard let match = line.firstMatch(of: /^(\d+)\.\s+(.+)$/) else { return nil } return String(match.2) } /// True if a line (already outdented to its level) starts a list item at column 0. func isListMarkerLine(_ line: String) -> Bool { line.hasPrefix("- ") || line.hasPrefix("+ ") || orderedListItem(in: line) != nil } func isIndentedContinuationLine(_ line: String) -> Bool { guard !line.trimmingCharacters(in: .whitespaces).isEmpty else { return false } guard let first = line.first else { return false } return first == " " || first == "\t" }