#![crate_name = "markly"]
#![deny(missing_docs)]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate regex;
#[macro_use]
extern crate pipeline;
#[macro_use]
extern crate lazy_static;
use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
mod html;
mod markdown_generator;
mod parser;
pub use parser::{Block, ListItem, Span};
pub fn to_html(text: &str) -> String {
let result = parser::parse(text);
html::to_html(&result)
}
pub fn tokenize(text: &str) -> Vec<Block> {
parser::parse(text)
}
pub fn generate_markdown(x: Vec<Block>) -> String {
markdown_generator::generate(x)
}
pub fn file_to_html(path: &Path) -> io::Result<String> {
let mut file = File::open(path)?;
let mut text = String::new();
file.read_to_string(&mut text)?;
let result = parser::parse(&text);
Ok(html::to_html(&result))
}