#tangle #org-mode #source #block #literate-programming

yanked org-tangle

A faster way to tangle org-mode

0.1.5 Oct 5, 2018
0.1.4 Oct 2, 2018
0.1.0 Sep 14, 2018

#15 in #org-mode


Used in 3 crates

GPL-3.0 license

13KB
299 lines

org-tangle

Build Status

A command line tool to tangle code blocks in org file to source code file.

  • A faster way to tangle org-mode.

Note About Restriction

  • The use case is restricted to global tangle property-line
    • code block level tangle property-line is NOT supported
    • headline level tangle property-line is NOT supported

I recommend ntangle, if you need more complete org-mode supports.

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 org-tangle

usage

USAGE:
    org-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 `.org` files
                 ignore `.org` files without tangle property

Example

In file engine.org

  • Add tangle property-line
#+property: tangle lib.rs
  • The following code block will be tangled into lib.rs
    • where code blocks are marked by #+begin_src <lang> and #+end_src
#+begin_src rust
fn tangle (string: &str) -> Result <String, TangleError> {
    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)
}
#+end_src
  • For a complete example, see this directory where engine.org is tangled to lib.rs

Dependencies

~1.5MB
~24K SLoC