main: added
This commit is contained in:
@@ -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.
|
||||
|
29
src/main.rs
Normal file
29
src/main.rs
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user