main: added

This commit is contained in:
2017-08-25 17:29:12 +02:00
parent a45eda2bd4
commit 02f5aee141
2 changed files with 32 additions and 0 deletions

View File

@@ -2,3 +2,6 @@
A browser engine written in Rust. I heard thats what the cool kids do these
days.
Current status: can read HTML/CSS, convert to internal representation, and back
to (unformatted) HTML/CSS.

29
src/main.rs Normal file
View File

@@ -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)
}