pub fn parse_header(l: &String) -> Page {
		let split_content = l.lines();
		let str_lines: Vec<&str> = split_content.collect();
		let mut lines = Vec::<String>::new();

		for str_line in str_lines {
		    let mut line = String::new();
		    line.push_str(str_line);
		    lines.push(line);
		}

        let mut meta = Vec::<Metadata>::new();
        let mut output = String::new();

        let mut in_reserved = false;
        for line_str in lines {
            let line = line_str.to_string();
            let first = first(&line).1;
            if len(&line) >= first + 6 {
                if slice(&line, first..first + 6) == "!meta!" && !in_reserved {
                    in_reserved = true;
                } else if slice(&line, first..first + 6) == "!meta!" && in_reserved {
                    in_reserved = false;
                } else if in_reserved {
                    if let Some(c_index) = line.find(':') {
                        let mut name = slice(&line, 0..c_index);
                        name = trim(&name, 0, 0).0;
                        let mut value = slice(&line, c_index + 1..len(&line));
                        value = trim(&value, 0, 0).0;
                        meta.push(Metadata { name, value });
                    }
                } else {
                    output.push_str(&line);
                    output.push('\n')
                }
            } else {
                output.push_str(&line);
                output.push('\n');
            }
        }
        Page {
            meta,
            content: output,
        }
    }
/*
    goes through the given String lines
    figures out if it's in the meta heading
    if it is, it starts generating a list of name: value pairs
    if it isn't, it just adds the line to the output
    it then returns a vec of Strings (the post), and a vec of Metadata (the name: value pairs)
    */
goes through the given String lines
figures out if it's in the meta heading
if it is, it starts generating a list of name: value pairs
if it isn't, it just adds the line to the output
it then returns a vec of Strings (the post), and a vec of Metadata (the name: value pairs)
goes through the given String lines figures out if it ' s in the meta heading if it is it starts generating a list of name : value pairs if it isn ' t it just adds the line to the output it then returns a vec of Strings ( the post ) and a vec of Metadata ( the name : value pairs )
pub fn parse_header(l: &String) -> Page {
		let split_content = l.lines();
		let str_lines: Vec<&str> = split_content.collect();
		let mut lines = Vec::<String>::new();
		for str_line in str_lines {
		    let mut line = String::new();
		    line.push_str(str_line);
		    lines.push(line);
		}
        let mut meta = Vec::<Metadata>::new();
        let mut output = String::new();
        let mut in_reserved = false;
        for line_str in lines {
            let line = line_str.to_string();
            let first = first(&line).1;
            if len(&line) >= first + 6 {
                if slice(&line, first..first + 6) == "!meta!" && !in_reserved {
                    in_reserved = true;
                } else if slice(&line, first..first + 6) == "!meta!" && in_reserved {
                    in_reserved = false;
                } else if in_reserved {
                    if let Some(c_index) = line.find(':') {
                        let mut name = slice(&line, 0..c_index);
                        name = trim(&name, 0, 0).0;
                        let mut value = slice(&line, c_index + 1..len(&line));
                        value = trim(&value, 0, 0).0;
                        meta.push(Metadata { name, value });
                    }
                } else {
                    output.push_str(&line);
                    output.push('\n')
                }
            } else {
                output.push_str(&line);
                output.push('\n');
            }
        }
        Page {
            meta,
            content: output,
        }
    }
pub fn parse_header ( l : & String ) -> Page { let split_content = l . lines ( ) ; let str_lines : Vec < & str > = split_content . collect ( ) ; let mut lines = Vec :: < String > :: new ( ) ; for str_line in str_lines { let mut line = String :: new ( ) ; line . push_str ( str_line ) ; lines . push ( line ) ; } let mut meta = Vec :: < Metadata > :: new ( ) ; let mut output = String :: new ( ) ; let mut in_reserved = false ; for line_str in lines { let line = line_str . to_string ( ) ; let first = first ( & line ) . 1 ; if len ( & line ) >= first + 6 { if slice ( & line , first .. first + 6 ) == " " && ! in_reserved { in_reserved = true ; } else if slice ( & line , first .. first + 6 ) == " " && in_reserved { in_reserved = false ; } else if in_reserved { if let Some ( c_index ) = line . find ( ':' ) { let mut name = slice ( & line , 0 .. c_index ) ; name = trim ( & name , 0 , 0 ) . 0 ; let mut value = slice ( & line , c_index + 1 .. len ( & line ) ) ; value = trim ( & value , 0 , 0 ) . 0 ; meta . push ( Metadata { name , value } ) ; } } else { output . push_str ( & line ) ; output . push ( '\n' ) } } else { output . push_str ( & line ) ; output . push ( '\n' ) ; } } Page { meta , content : output , } }
goes through the given String lines
figures out if it's in the meta heading
if it is, it starts generating a list of name: value pairs
if it isn't, it just adds the line to the output
it then returns a vec of Strings (the post), and a vec of Metadata (the name: value pairs)
goes through the given String lines figures out if it ' s in the meta heading if it is it starts generating a list of name : value pairs if it isn ' t it just adds the line to the output it then returns a vec of Strings ( the post ) and a vec of Metadata ( the name : value pairs )
l
&String
l
&String