swiftgemtext

[ACTIVE] gemtext parsing in swift
git clone git://git.figbert.com/swiftgemtext.git
Log | Files | Refs | README

commit e369ff7fb229a7174c3f77048d4e3303dd9d9453
parent 51dea98544e75035f72b38a800f0f2caddc96d87
Author: FIGBERT <figbert@figbert.com>
Date:   Sat,  3 Sep 2022 14:15:11 -0700

Pass gemtext on parse rather than initialization

Diffstat:
MSources/SwiftGemtext/SwiftGemtext.swift | 8+-------
MTests/SwiftGemtextTests/SwiftGemtextTests.swift | 6+++---
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/Sources/SwiftGemtext/SwiftGemtext.swift b/Sources/SwiftGemtext/SwiftGemtext.swift @@ -1,13 +1,7 @@ import SwiftUI struct Gemtext { - let source: String - - init(_ src: String) { - self.source = src - } - - func parse() -> [LineType] { + func parse(_ source: String) -> [LineType] { var lines = [LineType]() var pre = PreformattedState() diff --git a/Tests/SwiftGemtextTests/SwiftGemtextTests.swift b/Tests/SwiftGemtextTests/SwiftGemtextTests.swift @@ -4,7 +4,7 @@ import XCTest final class SwiftGemtextTests: XCTestCase { func testSingleLine() { let source = "This is an example line" - let run = Gemtext(source).parse() + let run = Gemtext().parse(source) XCTAssertEqual([LineType.Text(source)], run) } @@ -27,7 +27,7 @@ final class SwiftGemtextTests: XCTestCase { LineType.Link(URL(string: "gemini://figbert.com/")!, "figbert.com (gemini)"), LineType.Link(URL(string: "https://news.ycombinator.com/")!, "Hacker News"), ] - let run = Gemtext(source).parse() + let run = Gemtext().parse(source) XCTAssertEqual(manual, run) } @@ -75,7 +75,7 @@ final class SwiftGemtextTests: XCTestCase { LineType.Link(URL(string: "gemini://figbert.com/")!, nil), LineType.Link(URL(string: "gopher://mozz.us/")!, nil), ] - XCTAssertEqual(manual, Gemtext(source).parse()) + XCTAssertEqual(manual, Gemtext().parse(source)) } static var allTests = [