Crate netscape_bookmark_parser

Source
Expand description

§netscape_bookmark_parser

§Introduction

netscape_bookmark_parser is a Rust crate designed to parse HTML bookmark files (commonly exported from web browsers) and convert them into a structured JSON format. This crate provides functionality to read, parse, and transform bookmark data, making it easier to work with bookmarks programmatically.

§Features

  • HTML Bookmark Parsing: The crate can parse HTML files that contain browser bookmarks, extracting folder structures and individual bookmarks.
  • Timestamp Conversion: It handles the conversion of Unix timestamps to Windows NT timestamps, ensuring accurate date representation.
  • JSON Output: The parsed data is converted into a JSON structure, which can be easily integrated into other applications or stored for further processing.
  • Error Handling: Robust error handling ensures that issues with file paths or malformed HTML are gracefully managed.

§Usage

To use netscape_bookmark_parser, you can add it as a dependency in your Cargo.toml file:

cargo add netscape_bookmark_parser

Then, you can call the run function to process an HTML bookmarks file and output the result as a JSON file:

use netscape_bookmark_parser;

fn main() -> std::io::Result<()> {
    netscape_bookmark_parser::run("input.html", "output_directory")?;
    Ok(())
}

§install as CLI

cargo install netscape_bookmark_parser
# example
netscape_bookmark_parser -d html2json -i .\bookmark.html -o ./
netscape_bookmark_parser -d json2html -i .\bookmark.json -o ./

Modules§

generate_bookmark_html
generate_json_from_html
model