# md-tangle [![Build Status](https://travis-ci.org/parsing-tech/md-rs.svg?branch=master)](https://travis-ci.org/parsing-tech/md-rs) - [Main Repo](https://github.com/parsing-tech/md-rs) A command line tool to tangle code blocks in markdown file to source code file. ## Getting Start To build the program, nightly rust toolchain is needed. `rustup` is the tool to help programmers install rust toolchains. - One can get rustup from :: https://rustup.rs Then do: ``` rustup install nightly cargo +nightly install md-tangle ``` ## usage ``` USAGE: md-tangle [FLAGS] [PATH]... FLAGS: -r, --recursive recursively traverse -h, --help Prints help information -V, --version Prints version information ARGS: ... can be or ignore non unicode ignore non `.md` files ignore `.md` files without tangle property ``` ## Example In file `engine.md` - Add tangle property-line ``` --- tangle: lib.rs --- ``` - The following code block will be tangled into `lib.rs`

``` rust
fn tangle (string: &str) -> Result  {
    let mut result = String::new ();
    let mut lines = string.lines ();
    while let Some (line) = lines.next () {
        if block_begin_line_p (line) {
            tangle_collect (&mut result, &mut lines)?;
        }
    }
    Ok (result)
}
```
- For a complete example, see [this directory](https://github.com/parsing-tech/md-rs/tree/master/md-tangle-engine/src) where `engine.md` is tangled to `lib.rs` ## Related Project - [org-tangle](https://github.com/parsing-tech/org-rs/tree/master/org-tangle) -- same tool for org file.