Releases: danny1113/html-parser-builder
Release list
v4.0.2
v4.0.1
Fix compile error for Swift 5.9
Swift 5.9 doesn't support partial consume, so we have to consume self entirely first, then access its property.
error: 'self' consumed more than once
public consuming func map<NewOutput>(
^
note: consumed here
let parse = self._parse
^
note: consumed again here
return .init(selector: selector) { e in
^
Full Changelog: v4.0.0...v4.0.1
v4.0.0
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
2.0.0
Release 2.0
After 2 years, a new release finally arrived!
v2.0 is a major release, which contains some breaking changes.
- Use parameters packs in
HTMLComponentBuilder, removes a lot of boilerplate code! - Requires swift 5.9 or above.
- Without depends on any html parser.
- Now also available on Linux!
Type construction changes
There is some breaking changes in the type construction:
HTML {
Capture
Local {
Capture
Capture
}
}
previously the compiler will construct this output as (C, C, C),
but in version 2.0 this will be constructed as (C, (C, C)).
Build your own parser
HTMLParserBuilder now doesn't rely on any html parser, so you can chose any html parser you want to use, as long as it conforms to the Document and Element protocol.
For example, you can use SwiftSoup as the html parser, example for conformance to the Document and Element protocol is available in Tests/HTMLParserBuilderTests/SwiftSoup+HTMLParserBuilder.swift.
1.0.1
Changes
Add async variant.
public func parse<Output>(_ html: HTML<Output>) async throws -> OutputAdd test testLocalTransformAsync.
Change parsing algorithm.