diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9532114..5cdb68e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: run: | PLATFORM_NAME="${{ matrix.platform.name }}" if [[ "$PLATFORM_NAME" == "macOS" ]]; then - xcodebuild test -scheme ya-swift-html-xml-parser -destination "platform=macOS,arch=arm64" + xcodebuild test -scheme YaXHParser -destination "platform=macOS,arch=arm64" else GREP_PATTERN="${{ matrix.platform.grep }}" UDID=$(xcrun simctl list devices available | grep -m 1 "$GREP_PATTERN" | awk 'match($0, /\(([-0-9A-F]+)\)/) { print substr($0, RSTART + 1, RLENGTH - 2) }') @@ -58,7 +58,7 @@ jobs: echo "Found available ${PLATFORM_NAME} simulator with UDID: ${UDID}" - xcodebuild test -scheme ya-swift-html-xml-parser -destination "platform=${PLATFORM_NAME} Simulator,id=${UDID}" + xcodebuild test -scheme YaXHParser -destination "platform=${PLATFORM_NAME} Simulator,id=${UDID}" fi test-linux-stable: diff --git a/Package.swift b/Package.swift index d2e6154..6e4157a 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( - name: "ya-swift-html-xml-parser", + name: "YaXHParser", platforms: [ .macOS(.v15), .iOS(.v18), @@ -15,8 +15,8 @@ let package = Package( products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( - name: "ya-swift-html-xml-parser", - targets: ["ya-swift-html-xml-parser"] + name: "YaXHParser", + targets: ["YaXHParser"] ) ], dependencies: [], @@ -24,7 +24,7 @@ let package = Package( // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( - name: "ya-swift-html-xml-parser", + name: "YaXHParser", dependencies: ["CLibXML2", "LibXMLTrampolines"], swiftSettings: [ .swiftLanguageMode(.v6), @@ -48,9 +48,9 @@ let package = Package( ] ), .testTarget( - name: "ya-swift-html-xml-parserTests", + name: "YaXHParserTests", dependencies: [ - "ya-swift-html-xml-parser" + "YaXHParser" ] ) ] diff --git a/README.md b/README.md index 142c841..544d9d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ya-swift-html-xml-parser +# YaXHParser A tiny, modern Swift wrapper for `libxml2` that makes XML & HTML parsing easy, taking a-dvantage of the latest Swift features. @@ -29,7 +29,7 @@ A tiny, modern Swift wrapper for `libxml2` that makes XML & HTML parsing easy, t ## Installation -Add ya-swift-html-xml-parser as a dependency to your `Package.swift` file: +Add YaXHParser as a dependency to your `Package.swift` file: ```swift dependencies: [ @@ -50,7 +50,7 @@ A common task in web scraping is to find all URLs for media, links, or embedded This is especially useful for building scrapers for media sites (e.g., finding movie trailers or image galleries). ```swift -import ya_swift_html_xml_parser +import YaXHParser let mediaHTML = """
@@ -86,7 +86,7 @@ do { You can also perform basic queries and access element attributes and text content directly. ```swift -import ya_swift_html_xml_parser +import YaXHParser let html = """ @@ -122,7 +122,7 @@ do { Use `parseXML(string:)` for well-formed XML documents. By default, this function is **strict** and will throw an error if the XML is not perfectly well-formed. This is ideal for validation and ensuring data integrity. For more advanced control, see the "Parsing Strategies" section below. ```swift -import ya_swift_html_xml_parser +import YaXHParser let xml = """ @@ -210,7 +210,7 @@ The `ParsingService` actor provides a safe way to perform parsing operations fro A common use case is to offload parsing work from the main thread in a UI application to keep it responsive. The example below shows how to parse a batch of documents concurrently in a background task. ```swift -import ya_swift_html_xml_parser +import YaXHParser let service = ParsingService() let docsToParse = [ @@ -255,7 +255,7 @@ When using the `ParsingService`, keep the following in mind: `StreamParser` processes large documents piece-by-piece to minimize memory usage. You provide a custom handler to react to parsing events as they occur. ```swift -import ya_swift_html_xml_parser +import YaXHParser class MyEventHandler: StreamEventHandler { var elementCount = 0 @@ -279,9 +279,9 @@ do { ## Comparison to SwiftSoup -**[SwiftSoup](https://github.com/scinfu/SwiftSoup)** is a popular, pure-Swift HTML parser. `ya-swift-html-xml-parser` has a different design philosophy and may be suitable for different tasks. +**[SwiftSoup](https://github.com/scinfu/SwiftSoup)** is a popular, pure-Swift HTML parser. `YaXHParser` has a different design philosophy and may be suitable for different tasks. -| Feature | ya-swift-html-xml-parser | SwiftSoup | +| Feature | YaXHParser | SwiftSoup | |-----------------------|------------------------------------------------------|-------------------------------------------------------| | **Core Engine** | A thin Swift wrapper around the system's `libxml2` C library. | A feature-rich, pure Swift implementation. | | **Dependencies** | None (Foundation-free). | None (Pure Swift). | @@ -290,7 +290,7 @@ do { | **Concurrency** | Provides an actor for uncommon thread-safe parsing needs. | Thread-safety is managed by the user. | | **Ideal Use Case** | Fast data extraction and scraping where a minimal API is sufficient. | Projects that need to modify the DOM, or where a pure-Swift dependency is required. | -In short, choose **ya-swift-html-xml-parser** for a lightweight tool focused on fast data extraction. Choose **[SwiftSoup](https://github.com/scinfu/SwiftSoup)** when you need a comprehensive, pure-Swift toolkit for more complex DOM manipulation. +In short, choose **YaXHParser** for a lightweight tool focused on fast data extraction. Choose **[SwiftSoup](https://github.com/scinfu/SwiftSoup)** when you need a comprehensive, pure-Swift toolkit for more complex DOM manipulation. ## Local Development diff --git a/Sources/ya-swift-html-xml-parser/CSS/CSSError.swift b/Sources/YaXHParser/CSS/CSSError.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/CSS/CSSError.swift rename to Sources/YaXHParser/CSS/CSSError.swift diff --git a/Sources/ya-swift-html-xml-parser/CSS/CSSToXPath.swift b/Sources/YaXHParser/CSS/CSSToXPath.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/CSS/CSSToXPath.swift rename to Sources/YaXHParser/CSS/CSSToXPath.swift diff --git a/Sources/ya-swift-html-xml-parser/CSS/URLTagOptions.swift b/Sources/YaXHParser/CSS/URLTagOptions.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/CSS/URLTagOptions.swift rename to Sources/YaXHParser/CSS/URLTagOptions.swift diff --git a/Sources/ya-swift-html-xml-parser/CSS/XMLNode+CSS.swift b/Sources/YaXHParser/CSS/XMLNode+CSS.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/CSS/XMLNode+CSS.swift rename to Sources/YaXHParser/CSS/XMLNode+CSS.swift diff --git a/Sources/ya-swift-html-xml-parser/CSS/XMLNodeSet.swift b/Sources/YaXHParser/CSS/XMLNodeSet.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/CSS/XMLNodeSet.swift rename to Sources/YaXHParser/CSS/XMLNodeSet.swift diff --git a/Sources/ya-swift-html-xml-parser/Concurrency/ParsingService.swift b/Sources/YaXHParser/Concurrency/ParsingService.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Concurrency/ParsingService.swift rename to Sources/YaXHParser/Concurrency/ParsingService.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/ParsingOptions.swift b/Sources/YaXHParser/Core/ParsingOptions.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/ParsingOptions.swift rename to Sources/YaXHParser/Core/ParsingOptions.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/XMLDocument.swift b/Sources/YaXHParser/Core/XMLDocument.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/XMLDocument.swift rename to Sources/YaXHParser/Core/XMLDocument.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/XMLError.swift b/Sources/YaXHParser/Core/XMLError.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/XMLError.swift rename to Sources/YaXHParser/Core/XMLError.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/XMLNode+Traversal.swift b/Sources/YaXHParser/Core/XMLNode+Traversal.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/XMLNode+Traversal.swift rename to Sources/YaXHParser/Core/XMLNode+Traversal.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/XMLNode.swift b/Sources/YaXHParser/Core/XMLNode.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/XMLNode.swift rename to Sources/YaXHParser/Core/XMLNode.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/XMLNodeSequence.swift b/Sources/YaXHParser/Core/XMLNodeSequence.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/XMLNodeSequence.swift rename to Sources/YaXHParser/Core/XMLNodeSequence.swift diff --git a/Sources/ya-swift-html-xml-parser/Core/XMLNodeType.swift b/Sources/YaXHParser/Core/XMLNodeType.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Core/XMLNodeType.swift rename to Sources/YaXHParser/Core/XMLNodeType.swift diff --git a/Sources/ya-swift-html-xml-parser/Memory/MemoryParser.swift b/Sources/YaXHParser/Memory/MemoryParser.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Memory/MemoryParser.swift rename to Sources/YaXHParser/Memory/MemoryParser.swift diff --git a/Sources/ya-swift-html-xml-parser/Memory/MemoryParserOptions.swift b/Sources/YaXHParser/Memory/MemoryParserOptions.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Memory/MemoryParserOptions.swift rename to Sources/YaXHParser/Memory/MemoryParserOptions.swift diff --git a/Sources/ya-swift-html-xml-parser/Stream/ChunkSize.swift b/Sources/YaXHParser/Stream/ChunkSize.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Stream/ChunkSize.swift rename to Sources/YaXHParser/Stream/ChunkSize.swift diff --git a/Sources/ya-swift-html-xml-parser/Stream/StreamEvent.swift b/Sources/YaXHParser/Stream/StreamEvent.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Stream/StreamEvent.swift rename to Sources/YaXHParser/Stream/StreamEvent.swift diff --git a/Sources/ya-swift-html-xml-parser/Stream/StreamParser.swift b/Sources/YaXHParser/Stream/StreamParser.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Stream/StreamParser.swift rename to Sources/YaXHParser/Stream/StreamParser.swift diff --git a/Sources/ya-swift-html-xml-parser/Stream/StreamParserOptions.swift b/Sources/YaXHParser/Stream/StreamParserOptions.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Stream/StreamParserOptions.swift rename to Sources/YaXHParser/Stream/StreamParserOptions.swift diff --git a/Sources/ya-swift-html-xml-parser/Stream/StreamParserTrampolines.swift b/Sources/YaXHParser/Stream/StreamParserTrampolines.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Stream/StreamParserTrampolines.swift rename to Sources/YaXHParser/Stream/StreamParserTrampolines.swift diff --git a/Sources/ya-swift-html-xml-parser/Utils/String+Whitespace.swift b/Sources/YaXHParser/Utils/String+Whitespace.swift similarity index 100% rename from Sources/ya-swift-html-xml-parser/Utils/String+Whitespace.swift rename to Sources/YaXHParser/Utils/String+Whitespace.swift diff --git a/Tests/ya-swift-html-xml-parserTests/BasicParsingTests.swift b/Tests/YaXHParserTests/BasicParsingTests.swift similarity index 99% rename from Tests/ya-swift-html-xml-parserTests/BasicParsingTests.swift rename to Tests/YaXHParserTests/BasicParsingTests.swift index 093e0c9..470f076 100644 --- a/Tests/ya-swift-html-xml-parserTests/BasicParsingTests.swift +++ b/Tests/YaXHParserTests/BasicParsingTests.swift @@ -1,6 +1,6 @@ import Testing -@testable import ya_swift_html_xml_parser +@testable import YaXHParser #if canImport(Darwin) import Darwin.C diff --git a/Tests/ya-swift-html-xml-parserTests/ConcurrencyTests.swift b/Tests/YaXHParserTests/ConcurrencyTests.swift similarity index 98% rename from Tests/ya-swift-html-xml-parserTests/ConcurrencyTests.swift rename to Tests/YaXHParserTests/ConcurrencyTests.swift index ee8f937..48e4332 100644 --- a/Tests/ya-swift-html-xml-parserTests/ConcurrencyTests.swift +++ b/Tests/YaXHParserTests/ConcurrencyTests.swift @@ -1,6 +1,6 @@ import Testing -@testable import ya_swift_html_xml_parser +@testable import YaXHParser @Suite("Concurrency Tests") struct ConcurrencyTests { diff --git a/Tests/ya-swift-html-xml-parserTests/HTMLParsingTests.swift b/Tests/YaXHParserTests/HTMLParsingTests.swift similarity index 99% rename from Tests/ya-swift-html-xml-parserTests/HTMLParsingTests.swift rename to Tests/YaXHParserTests/HTMLParsingTests.swift index d26e966..d2d0271 100644 --- a/Tests/ya-swift-html-xml-parserTests/HTMLParsingTests.swift +++ b/Tests/YaXHParserTests/HTMLParsingTests.swift @@ -1,6 +1,6 @@ import Testing -@testable import ya_swift_html_xml_parser +@testable import YaXHParser @Suite("Real-World HTML Parsing") struct HTMLParsingTests { diff --git a/Tests/ya-swift-html-xml-parserTests/QueryTests.swift b/Tests/YaXHParserTests/QueryTests.swift similarity index 98% rename from Tests/ya-swift-html-xml-parserTests/QueryTests.swift rename to Tests/YaXHParserTests/QueryTests.swift index 9805205..6b3e625 100644 --- a/Tests/ya-swift-html-xml-parserTests/QueryTests.swift +++ b/Tests/YaXHParserTests/QueryTests.swift @@ -1,6 +1,6 @@ import Testing -@testable import ya_swift_html_xml_parser +@testable import YaXHParser @Suite("Querying (XPath & CSS)") struct QueryTests { diff --git a/Tests/ya-swift-html-xml-parserTests/StreamParserTests.swift b/Tests/YaXHParserTests/StreamParserTests.swift similarity index 98% rename from Tests/ya-swift-html-xml-parserTests/StreamParserTests.swift rename to Tests/YaXHParserTests/StreamParserTests.swift index 61f3130..a5dd1e2 100644 --- a/Tests/ya-swift-html-xml-parserTests/StreamParserTests.swift +++ b/Tests/YaXHParserTests/StreamParserTests.swift @@ -1,6 +1,6 @@ import Testing -@testable import ya_swift_html_xml_parser +@testable import YaXHParser #if canImport(Darwin) import Darwin.C