Skip to content

Releases: danny1113/html-parser-builder

v4.0.2

Choose a tag to compare

@danny1113 danny1113 released this 05 Mar 09:39
  • Add more documentation

Full Changelog: v4.0.1...v4.0.2

v4.0.1

Choose a tag to compare

@danny1113 danny1113 released this 25 Feb 00:39

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

Choose a tag to compare

@danny1113 danny1113 released this 24 Feb 13:45

Full Changelog: v3.0.0...v4.0.0

v3.0.0

Choose a tag to compare

@danny1113 danny1113 released this 23 Feb 05:46

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

  • CaptureOne
  • TryCaptureZeroOrOne
  • CaptureAllMany
  • LocalGroup

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: ErootElement: E?
  • id: Stringid: String?
  • tryQuerySelector(_ selector:) throwsquery(selector:) throws
  • querySelectorAll(_:)queryAll(selector:)
  • Remove querySelector(_:) -> Self?, use query(selector:) throws instead

Full Changelog: 2.0.0...v3.0.0

2.0.0

Choose a tag to compare

@danny1113 danny1113 released this 11 Jun 09:04
2ecadd3

Release 2.0

After 2 years, a new release finally arrived!

v2.0 is a major release, which contains some breaking changes.

  1. Use parameters packs in HTMLComponentBuilder, removes a lot of boilerplate code!
  2. Requires swift 5.9 or above.
  3. Without depends on any html parser.
  4. 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

Choose a tag to compare

@danny1113 danny1113 released this 16 Jul 11:30

Changes

Add async variant.

public func parse<Output>(_ html: HTML<Output>) async throws -> Output

Add test testLocalTransformAsync.
Change parsing algorithm.

Known Issues

1.0.0

Choose a tag to compare

@danny1113 danny1113 released this 14 Jul 16:10

initial release