Repository navigation
v3.0.0
This is the next major release, with breaking changes that you may need to change your code.
Swift 6 Language Mode
Swift 6 language mode is now enabled for this package.
I have to remove the async version of parse(_:) for now because it violates the Swift 6 concurrency rules.
Rewrite the parse implementation
The parse implementation has been fully rewritten.
Perviously it relied on compiler internal detail to construct strongly typed tuple from [Any],
now it uses parameter pack to construct the result tuple.
Zero Dependency
HTMLParserBuilder now splits its tests to another package, remove SwiftSoup from the dependency.
Now you have to bring your own html parser and implement the Document and Element protocol,
you can check out the examples in Sources/HTMLParserBuilder/Example.
Rename
Capture→OneTryCapture→ZeroOrOneCaptureAll→ManyLocal→Group
Refactor
Previously, you can add a transform argument, it's now changed to map:
// v2.0
HTML {
One("h1", transform: \.textContent)
One("h2", transform: \.textContent)
} transform: { output -> Pair in
Pair(output)
}
Group("#group") {
One("h1", transform: \.textContent)
One("h2", transform: \.textContent)
} transform: { output -> Pair in
Pair(output)
}// v3.0
HTML {
One("h1", transform: \.textContent)
One("h2", transform: \.textContent)
}
.map { output -> [Pair] in
Pair(output)
}
Group("#group") {
One("h1", transform: \.textContent)
One("h2", transform: \.textContent)
}
.map { output -> [Pair] in
Pair(output)
}Protocol Requirements
rootElement: E→rootElement: E?id: String→id: String?tryQuerySelector(_ selector:) throws→query(selector:) throwsquerySelectorAll(_:)→queryAll(selector:)- Remove
querySelector(_:) -> Self?, usequery(selector:) throwsinstead
Full Changelog: 2.0.0...v3.0.0