commit d9db4b17297f17cbccbfa025f3dd494027fd4291
parent 1599e254e9f14b2fdac971fed6b1ccfa5300a65f
Author: FIGBERT <figbert@figbert.com>
Date: Tue, 20 Apr 2021 00:57:11 -0700
Fix faulty line split implementation
The second test, testPlainGemini, now passes correctly.
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Sources/SwiftGemtext/SwiftGemtext.swift b/Sources/SwiftGemtext/SwiftGemtext.swift
@@ -10,7 +10,7 @@ struct SwiftGemtext {
func parse() -> [LineType] {
var lines = [LineType]()
var pre = false
- for line in source.lines {
+ for line in source.lines() {
let ln = String(line)
if pre {
if ln.starts(with: "```") {
@@ -75,5 +75,11 @@ enum LineType: Equatable {
}
extension StringProtocol {
- var lines: [SubSequence] { split(whereSeparator: \.isNewline) }
+ func lines() -> [String] {
+ var lines = [String]()
+ self.enumerateLines { line, _ in
+ lines.append(line)
+ }
+ return lines
+ }
}