diff --git a/README.md b/README.md index 081a10d..4f55868 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,6 @@ A browser engine written in Rust. I heard that’s what the cool kids do these days. + +Current status: can read HTML/CSS, convert to internal representation, and back +to (unformatted) HTML/CSS. diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c439912 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,29 @@ +extern crate getopts; + +use std::io::Read; +use std::fs::File; + +pub mod css; +pub mod dom; +pub mod html; + +fn read_source(filename: String) -> String { + let mut str = String::new(); + File::open(filename).unwrap().read_to_string(&mut str).unwrap(); + str +} + +fn main() { + let mut opts = getopts::Options::new(); + opts.optopt("h", "html", "HTML document", "FILENAME"); + + let matches = opts.parse(std::env::args().skip(1)).unwrap(); + let str_arg = |flag: &str, default: &str| -> String { + matches.opt_str(flag).unwrap_or(default.to_string()) + }; + + let html = read_source(str_arg("h", "examples/test.html")); + let node = html::parse(html); + + println!("{}", node) +}