diff --git a/Source/AcknowParser.swift b/Source/AcknowParser.swift index 0970f85..a40aaf3 100644 --- a/Source/AcknowParser.swift +++ b/Source/AcknowParser.swift @@ -91,23 +91,7 @@ open class AcknowParser { (preferenceSpecifier: AnyObject) -> Acknow in if let title = preferenceSpecifier["Title"] as! String?, let text = preferenceSpecifier["FooterText"] as! String? { - - // This regex replaces single newlines with spaces, while preserving multiple newlines used for formatting. - // This prevents issues such as https://github.com/vtourraine/AcknowList/issues/41 - // - // The issue arises when licenses contain premature line breaks in the middle of a sentance, often used - // to limit license texts to 80 characters. When applied on an iPad, the resulting licenses are misaligned. - // - // The expression (?<=.)(\h)*(\R)(\h)*(?=.) can be broken down as: - // - // (?<=.) Positive lookbehind matching any non-newline character (matches but does not capture) - // (\h)* Matches and captures zero or more horizontal spaces (trailing newlines) - // (\R) Matches and captures any single Unicode-compliant newline character - // (\h)* Matches and captures zero or more horizontal spaces (leading newlines) - // (?=.) Positive lookahead matching any non-newline character (matches but does not capture) - let singleNewLineFinder = try! NSRegularExpression(pattern: "(?<=.)(\\h)*(\\R)(\\h)*(?=.)") - let textWithoutNewlines = singleNewLineFinder.stringByReplacingMatches(in: text, range: NSRange(0.. String { + // This regex replaces single newlines with spaces, while preserving multiple newlines used for formatting. + // This prevents issues such as https://github.com/vtourraine/AcknowList/issues/41 + // + // The issue arises when licenses contain premature line breaks in the middle of a sentance, often used + // to limit license texts to 80 characters. When applied on an iPad, the resulting licenses are misaligned. + // + // The expression (?<=.)(\h)*(\R)(\h)*(?=.) can be broken down as: + // + // (?<=.) Positive lookbehind matching any non-newline character (matches but does not capture) + // (\h)* Matches and captures zero or more horizontal spaces (trailing newlines) + // (\R) Matches and captures any single Unicode-compliant newline character + // (\h)* Matches and captures zero or more horizontal spaces (leading newlines) + // (?=.) Positive lookahead matching any non-newline character (matches but does not capture) + let singleNewLineFinder = try! NSRegularExpression(pattern: "(?<=.)(\\h)*(\\R)(\\h)*(?=.)") + return singleNewLineFinder.stringByReplacingMatches(in: text, range: NSRange(0..