kuchiki-rs / kuchiki

(朽木) HTML/XML tree manipulation library for Rust
MIT License
470 stars 54 forks source link

QualName is not re-exported, so right now can not create new elements #94

Closed temach closed 1 year ago

temach commented 2 years ago

Running into trouble when I want to create a new element NodeRef.

I have tried two ways:

The error I get:

error[E0308]: mismatched types
   --> src/main.rs:135:53
    |
135 |                 let base_tag = NodeRef::new_element(name, ...);
    |                                                     ^^^^ expected struct `markup5ever::interface::QualName`, found struct `QualName`
    |
    = note: perhaps two different versions of crate `markup5ever` are being used?

Both of the functions take a QualName parameter. This struct is not re-exported by kuchiki (from html5ever). The only way to create its instance is to use html5ever (or markup5ever, but html5ever just re-exports QualName from markup5ever) . But right now the latest version of html5ever and version of html5ever used in kuchiki are not compatiable.

Here is the output of cargo tree, see that kuchiki and html5ever use different versions:

├── html5ever v0.26.0
│   ├── log v0.4.17 (*)
│   ├── mac v0.1.1
│   └── markup5ever v0.11.0
│       ├── log v0.4.17 (*)
│       ├── phf v0.10.1
│       │   └── phf_shared v0.10.0
│       │       └── siphasher v0.3.10
│       ├── string_cache v0.8.4
│       │   ├── new_debug_unreachable v1.0.4
│       │   ├── once_cell v1.12.0
│       │   ├── parking_lot v0.12.1 (*)
│       │   ├── phf_shared v0.10.0 (*)
│       │   ├── precomputed-hash v0.1.1
│       │   └── serde v1.0.137 (*)
│       └── tendril v0.4.3
│           ├── futf v0.1.5
│           │   ├── mac v0.1.1
│           │   └── new_debug_unreachable v1.0.4
│           ├── mac v0.1.1
│           └── utf-8 v0.7.6
│       [build-dependencies]
│       ├── phf_codegen v0.10.0
│       │   ├── phf_generator v0.10.0
│       │   │   ├── phf_shared v0.10.0 (*)
│       │   │   └── rand v0.8.5
│       │   │       ├── libc v0.2.126
│       │   │       ├── rand_chacha v0.3.1 (*)
│       │   │       └── rand_core v0.6.3 (*)
│       │   └── phf_shared v0.10.0 (*)
│       └── string_cache_codegen v0.5.2
│           ├── phf_generator v0.10.0 (*)
│           ├── phf_shared v0.10.0 (*)
│           ├── proc-macro2 v1.0.40 (*)
│           └── quote v1.0.20 (*)
│   [build-dependencies]
│   ├── proc-macro2 v1.0.40 (*)
│   ├── quote v1.0.20 (*)
│   └── syn v1.0.98 (*)
├── kuchiki v0.8.1
│   ├── cssparser v0.27.2
│   │   ├── cssparser-macros v0.6.0 (proc-macro)
│   │   │   ├── quote v1.0.20 (*)
│   │   │   └── syn v1.0.98 (*)
│   │   ├── dtoa-short v0.3.3
│   │   │   └── dtoa v0.4.8
│   │   ├── itoa v0.4.8
│   │   ├── matches v0.1.9
│   │   ├── phf v0.8.0
│   │   │   ├── phf_macros v0.8.0 (proc-macro)
│   │   │   │   ├── phf_generator v0.8.0
│   │   │   │   │   ├── phf_shared v0.8.0
│   │   │   │   │   │   └── siphasher v0.3.10
│   │   │   │   │   └── rand v0.7.3
│   │   │   │   │       ├── getrandom v0.1.16
│   │   │   │   │       │   ├── cfg-if v1.0.0
│   │   │   │   │       │   └── libc v0.2.126
│   │   │   │   │       ├── libc v0.2.126
│   │   │   │   │       ├── rand_chacha v0.2.2
│   │   │   │   │       │   ├── ppv-lite86 v0.2.16
│   │   │   │   │       │   └── rand_core v0.5.1
│   │   │   │   │       │       └── getrandom v0.1.16 (*)
│   │   │   │   │       ├── rand_core v0.5.1 (*)
│   │   │   │   │       └── rand_pcg v0.2.1
│   │   │   │   │           └── rand_core v0.5.1 (*)
│   │   │   │   ├── phf_shared v0.8.0 (*)
│   │   │   │   ├── proc-macro-hack v0.5.19 (proc-macro)
│   │   │   │   ├── proc-macro2 v1.0.40 (*)
│   │   │   │   ├── quote v1.0.20 (*)
│   │   │   │   └── syn v1.0.98 (*)
│   │   │   ├── phf_shared v0.8.0 (*)
│   │   │   └── proc-macro-hack v0.5.19 (proc-macro)
│   │   └── smallvec v1.9.0
│   │   [build-dependencies]
│   │   ├── proc-macro2 v1.0.40 (*)
│   │   ├── quote v1.0.20 (*)
│   │   └── syn v1.0.98 (*)
│   ├── html5ever v0.25.2
│   │   ├── log v0.4.17 (*)
│   │   ├── mac v0.1.1
│   │   └── markup5ever v0.10.1
│   │       ├── log v0.4.17 (*)
│   │       ├── phf v0.8.0 (*)
│   │       ├── string_cache v0.8.4 (*)
│   │       └── tendril v0.4.3 (*)
│   │       [build-dependencies]
│   │       ├── phf_codegen v0.8.0
│   │       │   ├── phf_generator v0.8.0 (*)
│   │       │   └── phf_shared v0.8.0 (*)
│   │       └── string_cache_codegen v0.5.2 (*)
│   │   [build-dependencies]
│   │   ├── proc-macro2 v1.0.40 (*)
│   │   ├── quote v1.0.20 (*)
│   │   └── syn v1.0.98 (*)
│   ├── matches v0.1.9
│   └── selectors v0.22.0
│       ├── bitflags v1.3.2
│       ├── cssparser v0.27.2 (*)
│       ├── derive_more v0.99.17 (proc-macro) (*)
│       ├── fxhash v0.2.1
│       │   └── byteorder v1.4.3
│       ├── log v0.4.17 (*)
│       ├── matches v0.1.9
│       ├── phf v0.8.0 (*)
│       ├── precomputed-hash v0.1.1
│       ├── servo_arc v0.1.1
│       │   ├── nodrop v0.1.14
│       │   └── stable_deref_trait v1.2.0
│       ├── smallvec v1.9.0
│       └── thin-slice v0.1.1
│       [build-dependencies]
│       └── phf_codegen v0.8.0 (*)

I think the simple solution would be to re-export QualName from html5ever, then I could use kuchiki::QualName which would definitely be compatible and avoid type mismatch error.

Ygg01 commented 2 years ago

That or maybe bump the version of html5ever

SimonSapin commented 1 year ago

I will soon archive this repository and make it read-only, so this issue will not be addressed: https://github.com/kuchiki-rs/kuchiki#archived