diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3072ea0..086e472 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: jobs: mix_test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 env: MIX_ENV: test HTML5EVER_BUILD: "true" @@ -19,17 +19,17 @@ jobs: fail-fast: false matrix: include: - - pair: - elixir: 1.12.3 - otp: 23.3.4 - pair: elixir: 1.14.5 - otp: "26.0" + otp: "24.3" + - pair: + elixir: 1.18.4 + otp: "27.3" lint: lint steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: erlef/setup-beam@v1.15 + - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.pair.otp }} elixir-version: ${{ matrix.pair.elixir }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fd6a88..ad560ab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,10 @@ name: Build precompiled NIFs +permissions: + id-token: write + attestations: write + contents: write + on: push: branches: @@ -26,23 +31,22 @@ jobs: strategy: fail-fast: false matrix: - nif: ["2.16", "2.15"] + nif: ["2.15"] job: - - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true } - - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true } - - { target: aarch64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true } - - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true } - - { target: aarch64-apple-darwin , os: macos-11 } - - { target: riscv64gc-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true } - - { target: x86_64-apple-darwin , os: macos-11 } - - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 } - - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true } - - { target: x86_64-pc-windows-gnu , os: windows-2019 } - - { target: x86_64-pc-windows-msvc , os: windows-2019 } + - { target: arm-unknown-linux-gnueabihf , os: ubuntu-22.04 , use-cross: true } + - { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04 , use-cross: true } + - { target: aarch64-unknown-linux-musl , os: ubuntu-22.04 , use-cross: true } + - { target: aarch64-apple-darwin , os: macos-13 } + - { target: riscv64gc-unknown-linux-gnu , os: ubuntu-22.04 , use-cross: true } + - { target: x86_64-apple-darwin , os: macos-13 } + - { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04 } + - { target: x86_64-unknown-linux-musl , os: ubuntu-22.04 , use-cross: true } + - { target: x86_64-pc-windows-gnu , os: windows-2022 } + - { target: x86_64-pc-windows-msvc , os: windows-2022 } steps: - name: Checkout source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Extract project version shell: bash @@ -58,7 +62,7 @@ jobs: - name: Build the project id: build-crate - uses: philss/rustler-precompiled-action@v1.0.1 + uses: philss/rustler-precompiled-action@v1.1.4 with: project-name: html5ever_nif project-version: ${{ env.PROJECT_VERSION }} @@ -67,8 +71,13 @@ jobs: use-cross: ${{ matrix.job.use-cross }} project-dir: "native/html5ever_nif" + - name: Artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-path: ${{ steps.build-crate.outputs.file-path }} + - name: Artifact upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.build-crate.outputs.file-name }} path: ${{ steps.build-crate.outputs.file-path }} @@ -79,7 +88,7 @@ jobs: echo "${{ steps.build-crate.outputs.file-sha256 }} ${{ steps.build-crate.outputs.file-name }}" >> $GITHUB_STEP_SUMMARY - name: Publish archives and packages - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | ${{ steps.build-crate.outputs.file-path }} diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 919cd6d..fb66725 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -13,14 +13,14 @@ on: jobs: lint-rust: name: Lint Rust - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: manifest: - native/html5ever_nif/Cargo.toml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d77e6d..5aa378d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.17.0] - 2025-08-15 + +### Changed + +- Require at least Rustler v0.36.0 + +- Require at least RustlerPrecompiled v0.8. + This is dropping support for versions 0.6 and 0.7 of that dependency. + +- Use newer versions of OS images to build the precompiled artifacts. + Some of the images we were using are deprecated. + Updated `ubuntu-20.04` to `ubuntu-22.04`, `macos-11` to `macos-13` and + `windows-2019` to `windows-2022`. Those changes may break systems running + in older versions of the related operational system. + +### Removed + +- Remove support for Elixir 1.13. + +## [0.16.1] - 2024-05-15 + +### Fixed + +- Fix parsing of HTML documents that may start with a comment or an XML doc tag. + +## [0.16.0] - 2024-03-25 + +### Fixed + +- Fix parsing of comments in `parse/1`. +- Avoid panic when parsing content with the "template" tag. + +### Removed + +- Drop support for Elixir 1.12 + ## [0.15.0] - 2023-06-16 ### Added @@ -160,7 +196,10 @@ is not needed for most of people using this project. - Add support for OTP 24. This was achieved by updating Rustler to v0.22. -[Unreleased]: https://github.com/rusterlium/html5ever_elixir/compare/v0.15.0...HEAD +[Unreleased]: https://github.com/rusterlium/html5ever_elixir/compare/v0.17.0...HEAD +[0.17.0]: https://github.com/rusterlium/html5ever_elixir/compare/v0.16.1...v0.17.0 +[0.16.1]: https://github.com/rusterlium/html5ever_elixir/compare/v0.16.0...v0.16.1 +[0.16.0]: https://github.com/rusterlium/html5ever_elixir/compare/v0.15.0...v0.16.0 [0.15.0]: https://github.com/rusterlium/html5ever_elixir/compare/v0.14.3...v0.15.0 [0.14.3]: https://github.com/rusterlium/html5ever_elixir/compare/v0.14.2...v0.14.3 [0.14.2]: https://github.com/rusterlium/html5ever_elixir/compare/v0.14.1...v0.14.2 diff --git a/README.md b/README.md index e1b4ad4..dad97f1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The package can be installed by adding `html5ever` to your list of dependencies ```elixir def deps do - [{:html5ever, "~> 0.15.0"}] + [{:html5ever, "~> 0.17.0"}] end ``` @@ -39,7 +39,7 @@ the compilation: ```elixir def deps do [ - {:html5ever, "~> 0.15.0"}, + {:html5ever, "~> 0.17.0"}, {:rustler, ">= 0.0.0", optional: true} ] end diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md index f7a97b4..12d8776 100644 --- a/RELEASE_CHECKLIST.md +++ b/RELEASE_CHECKLIST.md @@ -7,10 +7,16 @@ In order to release a new version to Hex.pm we first need to: 3. commit and create a tag for that version 4. push the changes to the repository with: `git push origin master --tags` 5. wait the CI to build all release files -6. run `mix rustler.download Html5ever.Native --all --print` +6. run `HTML5EVER_BUILD=1 mix rustler_precompiled.download Html5ever.Native --all --print` 7. copy the output of the mix task and add to the release notes -8. run `mix hex.publish` and **make sure the checksum file is present** -in the list of files to be published. +8. make sure the `target` directory is removed with + `rm -rf native/html5ever_elixir/target` +9. run `mix hex.publish` and **make sure the checksum file is present** + in the list of files to be published. + The checksum file is named `checksum-Elixir.Html5ever.Native.exs`. +10. after releasing, change the mix package version to include a `-dev` + suffix, so precompilation is ignored for development. You need + to commit and push this change. It's important to ensure that we publish the checksum file with the package because otherwise the users won't be able to use the lib diff --git a/mix.exs b/mix.exs index 5a49d29..304e562 100644 --- a/mix.exs +++ b/mix.exs @@ -1,14 +1,14 @@ defmodule Html5ever.Mixfile do use Mix.Project - @version "0.15.0" + @version "0.17.0-dev" @repo_url "https://github.com/rusterlium/html5ever_elixir" def project do [ app: :html5ever, version: @version, - elixir: "~> 1.12", + elixir: "~> 1.14", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, deps: deps(), @@ -24,8 +24,8 @@ defmodule Html5ever.Mixfile do defp deps do [ - {:rustler_precompiled, "~> 0.5.2 or ~> 0.6.0"}, - {:rustler, ">= 0.0.0", optional: true}, + {:rustler_precompiled, "~> 0.8"}, + {:rustler, "~> 0.36", optional: true}, {:ex_doc, ">= 0.0.0", only: :dev} ] end diff --git a/mix.lock b/mix.lock index 6720f3f..1e3db4f 100644 --- a/mix.lock +++ b/mix.lock @@ -1,13 +1,13 @@ %{ - "castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"}, - "ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"}, - "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, - "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"}, - "rustler": {:hex, :rustler, "0.28.0", "b8e2c43013e12dd06f61dcf87033d2e2c8245feddb121b82179c923be31ad319", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "99f811f58c993f0343851adb0af589a99cfd3dc20f2efb8ef08d1a8447980b98"}, - "rustler_precompiled": {:hex, :rustler_precompiled, "0.6.1", "160b545bce8bf9a3f1b436b2c10f53574036a0db628e40f393328cbbe593602f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "0dd269fa261c4e3df290b12031c575fff07a542749f7b0e8b744d72d66c43600"}, + "castore": {:hex, :castore, "1.0.15", "8aa930c890fe18b6fe0a0cff27b27d0d4d231867897bd23ea772dee561f032a3", [:mix], [], "hexpm", "96ce4c69d7d5d7a0761420ef743e2f4096253931a3ba69e5ff8ef1844fe446d3"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, + "ex_doc": {:hex, :ex_doc, "0.38.3", "ddafe36b8e9fe101c093620879f6604f6254861a95133022101c08e75e6c759a", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "ecaa785456a67f63b4e7d7f200e8832fa108279e7eb73fd9928e7e66215a01f9"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"}, + "rustler": {:hex, :rustler, "0.36.2", "6c2142f912166dfd364017ab2bf61242d4a5a3c88e7b872744642ae004b82501", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.7", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "93832a6dbc1166739a19cd0c25e110e4cf891f16795deb9361dfcae95f6c88fe"}, + "rustler_precompiled": {:hex, :rustler_precompiled, "0.8.3", "4e741024b0b097fe783add06e53ae9a6f23ddc78df1010f215df0c02915ef5a8", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "c23f5f33cb6608542de4d04faf0f0291458c352a4648e4d28d17ee1098cddcc4"}, "toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"}, } diff --git a/native/html5ever_nif/.cargo/config b/native/html5ever_nif/.cargo/config.toml similarity index 60% rename from native/html5ever_nif/.cargo/config rename to native/html5ever_nif/.cargo/config.toml index 142360b..89a707d 100644 --- a/native/html5ever_nif/.cargo/config +++ b/native/html5ever_nif/.cargo/config.toml @@ -1,18 +1,6 @@ [profile.release] lto = true -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - -[target.aarch64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - [target.arm-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc" diff --git a/native/html5ever_nif/Cargo.lock b/native/html5ever_nif/Cargo.lock index 0360adf..e8d3f8f 100644 --- a/native/html5ever_nif/Cargo.lock +++ b/native/html5ever_nif/Cargo.lock @@ -1,33 +1,24 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" -dependencies = [ - "memchr", -] +version = 4 [[package]] name = "autocfg" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "futf" @@ -39,35 +30,24 @@ dependencies = [ "new_debug_unreachable", ] -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "html5ever" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4" dependencies = [ "log", "mac", "markup5ever", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -82,23 +62,42 @@ dependencies = [ "thiserror", ] +[[package]] +name = "inventory" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab08d7cd2c5897f2c949e5383ea7c7db03fb19130ffcfbf7eda795137ae3cb83" +dependencies = [ + "rustversion", +] + [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.146" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" + +[[package]] +name = "libloading" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +dependencies = [ + "cfg-if", + "windows-targets 0.53.3", +] [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -106,9 +105,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "mac" @@ -118,9 +117,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "markup5ever" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" +checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45" dependencies = [ "log", "phf", @@ -130,29 +129,17 @@ dependencies = [ "tendril", ] -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", "parking_lot_core", @@ -160,31 +147,31 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] name = "phf" -version = "0.10.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_shared", ] [[package]] name = "phf_codegen" -version = "0.10.0" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" dependencies = [ "phf_generator", "phf_shared", @@ -192,9 +179,9 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.10.0" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", "rand", @@ -202,19 +189,13 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.10.0" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ "siphasher", ] -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "precomputed-hash" version = "0.1.1" @@ -223,18 +204,18 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "d61789d7719defeb74ea5fe81f2fdfdbd28a803847077cecce2ff14e1472f6f1" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -245,18 +226,6 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", "rand_core", ] @@ -265,101 +234,98 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ "bitflags", ] [[package]] -name = "regex" -version = "1.8.4" +name = "regex-lite" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "rustler" -version = "0.28.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d7a2f98cb272ae0548e434bb3afde626012084cbebef84542bc7afed868bd6f" +checksum = "e3fe55230a9c379733dd38ee67d4072fa5c558b2e22b76b0e7f924390456e003" dependencies = [ - "lazy_static", + "inventory", + "libloading", + "regex-lite", "rustler_codegen", - "rustler_sys", ] [[package]] name = "rustler_codegen" -version = "0.28.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae37fb154683a1ff13e95dfd16c15043d6aee9853ea650ca34a45bd94e319a5" +checksum = "eb3b8de901ae61418e2036245d28e41ef58080d04f40b68430471ae36a4e84ed" dependencies = [ "heck", + "inventory", "proc-macro2", "quote", - "syn 2.0.18", + "syn", ] [[package]] -name = "rustler_sys" -version = "2.2.1" +name = "rustversion" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae0eb19e2fdf4abc3662441087fc499a58b7550822cc8007e79f15c40157c883" -dependencies = [ - "regex", - "unreachable", -] +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "siphasher" -version = "0.3.10" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "string_cache" -version = "0.8.7" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" dependencies = [ "new_debug_unreachable", - "once_cell", "parking_lot", "phf_shared", "precomputed-hash", @@ -368,9 +334,9 @@ dependencies = [ [[package]] name = "string_cache_codegen" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0" dependencies = [ "phf_generator", "phf_shared", @@ -380,20 +346,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.109" +version = "2.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619" dependencies = [ "proc-macro2", "quote", @@ -413,38 +368,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn", ] [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" - -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf-8" @@ -453,70 +399,136 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] -name = "void" -version = "1.0.2" +name = "windows-link" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" diff --git a/native/html5ever_nif/Cargo.toml b/native/html5ever_nif/Cargo.toml index 0e1e993..f2ef192 100644 --- a/native/html5ever_nif/Cargo.toml +++ b/native/html5ever_nif/Cargo.toml @@ -10,12 +10,13 @@ path = "src/lib.rs" crate-type = ["cdylib"] [dependencies] -rustler = "0.28.0" +# See the Precompilation guide for details about the features: https://github.com/philss/rustler_precompiled/blob/main/PRECOMPILATION_GUIDE.md +rustler = { version = "0.36", default-features = false, features = ["nif_version_2_15"] } -html5ever = "0.26" -markup5ever = "0.11" +html5ever = "0.27" +markup5ever = "0.12" tendril = "0.4" -lazy_static = "1.4" +lazy_static = "1.5" -thiserror = "1" +thiserror = "2" diff --git a/native/html5ever_nif/Cross.toml b/native/html5ever_nif/Cross.toml deleted file mode 100644 index 8ba543c..0000000 --- a/native/html5ever_nif/Cross.toml +++ /dev/null @@ -1,4 +0,0 @@ -[build.env] -passthrough = [ - "RUSTLER_NIF_VERSION" -] diff --git a/native/html5ever_nif/src/common.rs b/native/html5ever_nif/src/common.rs index 5ba3da2..ac97c7e 100644 --- a/native/html5ever_nif/src/common.rs +++ b/native/html5ever_nif/src/common.rs @@ -10,13 +10,13 @@ use tendril::StrTendril; pub struct QualNameWrapper<'a>(pub &'a QualName); pub struct StrTendrilWrapper<'a>(pub &'a StrTendril); -impl<'b> Encoder for QualNameWrapper<'b> { +impl Encoder for QualNameWrapper<'_> { fn encode<'a>(&self, env: Env<'a>) -> Term<'a> { let data: &str = &self.0.local; data.encode(env) } } -impl<'b> Encoder for StrTendrilWrapper<'b> { +impl Encoder for StrTendrilWrapper<'_> { fn encode<'a>(&self, env: Env<'a>) -> Term<'a> { let data: &str = self.0; data.encode(env) diff --git a/native/html5ever_nif/src/flat_dom.rs b/native/html5ever_nif/src/flat_dom.rs index e35e3dd..8c68479 100644 --- a/native/html5ever_nif/src/flat_dom.rs +++ b/native/html5ever_nif/src/flat_dom.rs @@ -23,7 +23,7 @@ impl PoolOrVec where T: Clone, { - pub fn new(pool: &Vec) -> Self { + pub fn new(pool: &[T]) -> Self { PoolOrVec::Pool { head: pool.len(), len: 0, @@ -116,7 +116,7 @@ pub struct Node { data: NodeData, } impl Node { - fn new(id: usize, data: NodeData, pool: &Vec) -> Self { + fn new(id: usize, data: NodeData, pool: &[NodeHandle]) -> Self { Node { id: NodeHandle(id), parent: None, @@ -214,14 +214,26 @@ impl TreeSink for FlatSink { fn get_document(&mut self) -> Self::Handle { NodeHandle(0) } - fn get_template_contents(&mut self, _target: &Self::Handle) -> Self::Handle { - panic!("Templates not supported"); + fn get_template_contents(&mut self, target: &Self::Handle) -> Self::Handle { + // Inspired in https://github.com/servo/html5ever/blob/1a62a39879a1def200dcb87b900265993e6c1c83/rcdom/lib.rs#L235 + // It is not getting the templates contents. But is printing the empty tag. + // TODO: print the contents as text. + let node = self.node(*target); + if let NodeData::Element { + ref template_contents, + .. + } = node.data + { + *template_contents.as_ref().expect("not a template element!") + } else { + panic!("not a template element!") + } } fn same_node(&self, x: &Self::Handle, y: &Self::Handle) -> bool { x == y } - fn elem_name(&self, target: &Self::Handle) -> ExpandedName { + fn elem_name(&self, target: &Self::Handle) -> ExpandedName<'_> { let node = self.node(*target); match node.data { NodeData::Element { ref name, .. } => name.expanded(), @@ -514,6 +526,8 @@ pub fn flat_sink_to_rec_term<'a>( child_base: 0, child_n: 0, }]; + let mut comments_bf_doctype = 0usize; + let mut read_doctype = false; loop { let mut top = stack.pop().unwrap(); @@ -555,7 +569,9 @@ pub fn flat_sink_to_rec_term<'a>( system_id, } => { assert!(!stack.is_empty()); - assert!(child_stack.is_empty()); + assert!(child_stack.is_empty() || comments_bf_doctype == child_stack.len()); + + read_doctype = true; term = ( atoms::doctype(), @@ -583,7 +599,13 @@ pub fn flat_sink_to_rec_term<'a>( NodeData::Text { contents } => { term = StrTendrilWrapper(contents).encode(env); } - NodeData::Comment { .. } => continue, + NodeData::Comment { contents } => { + if !read_doctype { + comments_bf_doctype += 1 + }; + + term = (atoms::comment(), StrTendrilWrapper(contents)).encode(env); + } _ => unimplemented!(""), } diff --git a/native/html5ever_nif/src/lib.rs b/native/html5ever_nif/src/lib.rs index b3aae21..e488f09 100644 --- a/native/html5ever_nif/src/lib.rs +++ b/native/html5ever_nif/src/lib.rs @@ -54,12 +54,4 @@ fn build_flat_sink(bin_slice: &[u8]) -> Result { Ok(parser.one(utf8)) } -rustler::init!( - "Elixir.Html5ever.Native", - [parse, flat_parse], - load = on_load -); - -fn on_load<'a>(_env: Env<'a>, _load_info: Term<'a>) -> bool { - true -} +rustler::init!("Elixir.Html5ever.Native"); diff --git a/test/html5ever_test.exs b/test/html5ever_test.exs index 94151e4..44797dc 100644 --- a/test/html5ever_test.exs +++ b/test/html5ever_test.exs @@ -8,9 +8,17 @@ defmodule Html5everTest do end test "parse basic html" do - html = "" + html = "

Hello

" - assert Html5ever.parse(html) == {:ok, [{"html", [], [{"head", [], []}, {"body", [], []}]}]} + assert Html5ever.parse(html) == + {:ok, + [ + {"html", [], + [ + {"head", [], []}, + {"body", [], [{"h1", [], ["Hello"]}, {:comment, " my comment "}]} + ]} + ]} end test "does not parse with not valid UTF8 binary" do @@ -271,4 +279,75 @@ defmodule Html5everTest do ]} ]} = parsed end + + test "parse html with a template tag ignores template content" do + html = """ + + + With template + +

Document

+ + + + """ + + assert Html5ever.parse(html) == + {:ok, + [ + {:doctype, "html", "", ""}, + {"html", [], + [ + {"head", [], [{"title", [], ["With template"]}]}, + "\n", + {"body", [], + ["\n", {"h1", [], ["Document"]}, "\n", {"template", [], []}, "\n", "\n", "\n"]} + ]} + ]} + end + + test "parse html starting with a XML tag" do + html = """ + + + + + Hello + + link + + + """ + + assert Html5ever.parse(html) == + {:ok, + [ + {:comment, "?xml version=\"1.0\" encoding=\"UTF-8\"?"}, + {:comment, " also a comment is allowed "}, + {:doctype, "html", "-//W3C//DTD XHTML 1.0 Strict//EN", + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"}, + { + "html", + [{"xmlns", "http://www.w3.org/1999/xhtml"}, {"xml:lang", "en"}, {"lang", "en"}], + [ + {"head", [], [{"title", [], ["Hello"]}]}, + "\n", + " ", + {"body", [], + [ + "\n", + " ", + {"a", [{"id", "anchor"}, {"href", "https://example.com"}], ["link"]}, + "\n", + " ", + "\n", + "\n" + ]} + ] + } + ]} + end end