html-parser-rs 0.1.0

A Rust crate for parsing HTML documents. It supports reading HTML documents in an event-based fashion.
Documentation
  • Coverage
  • 0%
    0 out of 9 items documented0 out of 4 items with examples
  • Size
  • Source code size: 8.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 434.01 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mdmahikaishar

Html Parser Rs

Rust License

html-parser-rs is a Rust crate for parsing HTML documents. It supports reading HTML documents in an event-based fashion. This allows you to receive events for different elements, attributes, and text content during the parsing process.

Features

  • Event-Based Parsing: Receive events for different elements, attributes, and text content during parsing.

Usage

Add this crate to your Cargo.toml file:

[dependencies]
html-parser-rs = "0.1.0"
use html_parser_rs::Lexer;
use std::fs;

fn main() {
    let contents = fs::read_to_string("./examples/index.html")
        .expect("Failed to read file.");

    let mut lexer = Lexer::new(contents);

    for token in lexer.parse() {
        println!("{token:?}");
    }
}

Events

  • StartElement(TAG_NAME): Triggered when an HTML element starts.

  • EndElement(TAG_NAME): Triggered when an HTML element ends.

  • TextContent(TEXT): Triggered when text content is encountered.

  • Attribute(NAME, VALUE): Triggered when an attribute is encountered.

Contributing

Contributions are welcome! I would like you to contribute in this project.

Roadmap

This project is in its early stages, and there are many missing features that need implementation. Check the Issues section for a list of features, enhancements, and bug fixes that are planned.

License

This project is licensed under the MIT License - see the LICENSE file for details.