1#![crate_name = "markdown"]
3#![deny(missing_docs)]
4#![cfg_attr(feature="clippy", feature(plugin))]
7#![cfg_attr(feature="clippy", plugin(clippy))]
8
9extern crate regex;
10
11#[macro_use]
12extern crate pipeline;
13
14#[macro_use]
15extern crate lazy_static;
16
17use std::fs::File;
18use std::path::Path;
19use std::io::{self, Read};
20
21mod parser;
22mod markdown_generator;
23mod html;
24
25pub use parser::{Block, ListItem, Span};
26
27pub fn to_html(text: &str) -> String {
29 let result = parser::parse(text);
30 html::to_html(&result)
31}
32
33pub fn tokenize(text: &str) -> Vec<Block> {
35 parser::parse(text)
36}
37
38pub fn generate_markdown(x: Vec<Block>) -> String {
40 markdown_generator::generate(x)
41}
42
43pub fn file_to_html(path: &Path) -> io::Result<String> {
45 let mut file = File::open(path)?;
46
47 let mut text = String::new();
48 file.read_to_string(&mut text)?;
49
50 let result = parser::parse(&text);
51 Ok(html::to_html(&result))
52}