From 11a2cc98f8117e0b8af80adf23a865dd26900725 Mon Sep 17 00:00:00 2001 From: zunda <47569369+zunda-pixel@users.noreply.github.com> Date: Wed, 4 Jun 2025 17:46:26 +0900 Subject: [PATCH 1/3] Create release.yml --- .github/workflows/release.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1c0cd7b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +name: Release + +on: + push: + tags: + - "*" + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: gh release create ${{ github.ref_name }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7833115e56d926f736b0be16bfed1bf68bcfb37b Mon Sep 17 00:00:00 2001 From: zunda <47569369+zunda-pixel@users.noreply.github.com> Date: Wed, 4 Jun 2025 17:48:09 +0900 Subject: [PATCH 2/3] Create ci.yml --- .github/workflows/ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..052a639 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,16 @@ +name: CI + +on: pull_request + +jobs: + test: + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + - run: swift build --build-tests + lint: + runs-on: ubuntu-24.04-arm + container: swift:latest + steps: + - uses: actions/checkout@v4 + - run: swift format lint -r -p -s . From 4d06cc331f78c9ef72f529966309da60e6f6a910 Mon Sep 17 00:00:00 2001 From: zunda <47569369+zunda-pixel@users.noreply.github.com> Date: Wed, 4 Jun 2025 18:19:15 +0900 Subject: [PATCH 3/3] format (#16) --- Package.swift | 6 +++--- .../AttributedText/AttributedString++.swift | 10 ++++++++-- Sources/AttributedText/AttributedText.swift | 19 ++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Package.swift b/Package.swift index 6d8c080..320bddb 100644 --- a/Package.swift +++ b/Package.swift @@ -10,17 +10,17 @@ let package = Package( .macOS(.v13), .watchOS(.v9), .tvOS(.v16), - .macCatalyst(.v16) + .macCatalyst(.v16), ], products: [ .library( name: "AttributedText", targets: ["AttributedText"] - ), + ) ], targets: [ .target( name: "AttributedText" - ), + ) ] ) diff --git a/Sources/AttributedText/AttributedString++.swift b/Sources/AttributedText/AttributedString++.swift index 6567b89..9b50ad3 100644 --- a/Sources/AttributedText/AttributedString++.swift +++ b/Sources/AttributedText/AttributedString++.swift @@ -6,12 +6,18 @@ import Foundation import RegexBuilder extension AttributedStringProtocol { - func range(_ pattern: String, options: String.CompareOptions? = nil) -> Range? { + func range( + _ pattern: String, + options: String.CompareOptions? = nil + ) -> Range? { let options = options?.union(.regularExpression) ?? .regularExpression return self.range(of: pattern, options: options) } - func ranges(_ pattern: String, options: String.CompareOptions? = nil) -> [Range] { + func ranges( + _ pattern: String, + options: String.CompareOptions? = nil + ) -> [Range] { guard let range = range(pattern, options: options) else { return [] } diff --git a/Sources/AttributedText/AttributedText.swift b/Sources/AttributedText/AttributedText.swift index 3bc8f84..f8d27ab 100644 --- a/Sources/AttributedText/AttributedText.swift +++ b/Sources/AttributedText/AttributedText.swift @@ -12,7 +12,7 @@ public struct AttributedText: View { let prefixAction: (String, String) -> Void let urlAction: ((URL) -> Void)? - + public init( text: String, prefixes: [AttributedPrefix], @@ -63,12 +63,14 @@ public struct AttributedText: View { } #Preview { - Preview(text: """ -url https://swift.org/ -hashtag #Swift -mention @Swift -and &swift -""") + Preview( + text: """ + url https://swift.org/ + hashtag #Swift + mention @Swift + and &swift + """ + ) .frame(maxWidth: 500, maxHeight: 500) } @@ -116,7 +118,6 @@ public struct Preview: View { } } - struct HashtagView: View { let hashtag: String @@ -176,7 +177,7 @@ struct ViewData: Codable, Hashable { struct WebView: View { let url: URL - + var body: some View { Text(url.absoluteString) }