use crate::parser::Markdown;
use crate::{error::Error, parser::parse};
pub fn read_file<P>(path: P) -> Result<Markdown, Error>
where
P: AsRef<std::path::Path>,
{
parse(std::fs::read_to_string(path)?.as_str())
}
pub fn write_file<P>(markdown: &Markdown, path: P) -> Result<(), Error>
where
P: AsRef<std::path::Path>,
{
use std::fs::File;
use std::io::prelude::Write;
let mut file = File::create(path)?;
file.write_all(&markdown.bytes())?;
Ok(())
}