#markdown #command-line-tool #tangle #source-file #blocks

yanked md-tangle

A command line tool to tangle code blocks in markdown file to source code file

0.1.4 Oct 5, 2018
0.1.3 Oct 3, 2018
0.1.2 Oct 3, 2018
0.1.1 Oct 3, 2018
0.1.0 Oct 2, 2018

#52 in #tangle

GPL-3.0 license

13KB
281 lines

md-tangle

Build Status

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.

Then do:

rustup install nightly
cargo +nightly install md-tangle

usage

USAGE:
    md-tangle [FLAGS] [PATH]...

FLAGS:
    -r, --recursive    recursively traverse <DIR>
    -h, --help         Prints help information
    -V, --version      Prints version information

ARGS:
    <PATH>...    <PATH> can be <FILE> or <DIR>
                 ignore non unicode <PATH>
                 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 where engine.md is tangled to lib.rs

Dependencies

~1.5MB
~24K SLoC