Crates.io | md |
lib.rs | md |
version | 0.0.1 |
source | src |
created_at | 2014-11-20 23:18:27.918437 |
updated_at | 2015-12-11 23:56:40.231265 |
description | A pure-Rust Markdown parser implementation, CommonMark-compatible |
homepage | |
repository | https://github.com/netvl/md.rs |
max_upload_size | |
id | 183 |
size | 52,230 |
md.rs
is intended to be a simple Markdown parser in Rust. It will provide token-based stream parser capabilities.
md.rs
uses Cargo, so just make a dependency on it in your Cargo.toml
manifest:
[dependencies.md]
git = "https://github.com/netvl/md.rs"
The main object in the library is md::MarkdownParser
struct. It implements
Iterator<md::tokens::Block>
trait, so you can use it in for
loop:
extern crate md;
use std::io::File;
use md::MarkdownParser;
use md::tokens::Heading;
fn main() {
let mut f = File::open("/some/markdown/document.md").unwrap();
let buf = f.read_to_end().unwrap();
let mut p = MarkdownParser::new(buf.as_slice());
for token in p {
match token {
Heading { level, content } =>
println!("Heading level {}, content: {}", level, content),
_ =>
}
}
}
See example programs in examples
subpackage.
This library is licensed under MIT license.
Copyright (C) Vladimir Matveev, 2014