html5ever icon indicating copy to clipboard operation
html5ever copied to clipboard

doc: how to run example, for n00bs

Open coolaj86 opened this issue 2 years ago • 3 comments

Re: https://github.com/servo/html5ever/pull/475

  1. Make sure your rustc version is 1.61.0 or greater
    rustup update
    rustup override unset
    rustup default stable
    rustc --version
    
  2. Create a new project
    mkdir -p ./my-print-rcdom/
    pushd ./my-print-rcdom/
    cargo init
    
  3. Update Cargo.toml to include the dependencies (also, 2018 appears to be the required edition)
    [package]
    name = "example01"
    version = "0.1.0"
    authors = ["Joe Doe <[email protected]>"]
    edition = "2018"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    html5ever = "0.25.2"
    markup5ever_rcdom = "0.1.0"
    
  4. Replace src/main.rs with the contents of, for example, ./rcdom/examples/print-rcdom.rs
    rm ./src/main.rs
    curl -L -o ./src/main.rs https://raw.githubusercontent.com/servo/html5ever/1b34cf17c/rcdom/examples/print-rcdom.rs
    
  5. Install, build, run (with input):
    cargo build
    curl https://example.com | cargo run
    

Troubleshooting

Weird bug:

warning: unused import: `html5ever::tendril::TendrilSink`
  --> src/main.rs:20:5
   |
20 | use html5ever::tendril::TendrilSink;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.

Changing the name field in Cargo.toml (to anything at all), saving, and running cargo install again.

A room full of rust developers, including one of the most popular teachers on udemy in the room here with us, cannot figure this out.

coolaj86 avatar Jun 10 '22 02:06 coolaj86