CLI tool to bake your fresh and hot MD files

Overview

Markdown Bakery

CLI tool to bake your fresh and hot MD files

About

At least once in your Rust dev lifetime you wanted to make sure all code examples in your markdown files are up-to-date, correct and code is formated, but you couldn't make that done with already existing tools - fear not!

Markdown Bakery allows you to create markdown template files with rust code injected from source files using special code block:

# Content of `./src/main.rs`:

```rust: source
./src/main.rs
```

After language part you tell MD Bakery this code part has to inject source code from path specified inside the code block.

If you want to escape MD Bakery code blocks you can put ! in front of source (sadly we can't show it here since that would print double ! in the readme file you read right now, more about why later).

If you prefer to inject different parts of the code file instead of keeping each code snippet in separate files, all you have to do is to inject named source:

# Snippet A:

```rust: source @ snippet-a
./src/main.rs
```

# Snippet B:

```rust: source @ snippet-b
./src/main.rs
```

And then in your source file you specify named blocks of the code where snippets are located, using comments like this:

use std::collections::HashMap;

// [md-bakery: begin @ snippet-a]
#[derive(Debug)]
struct Foo {
    bar: HashMap<String, usize>,
}
// [md-bakery: end]

fn main() {
    // [md-bakery: begin @ snippet-b]
    let foo = Foo {
        bar: {
            let mut result = HashMap::new();
            result.insert("answer".to_owned(), 42);
            result
        },
    };

    println!("{:?}", foo);
    // [md-bakery: end]
}

And then all of that renders into:

# Snippet A:

```rust
#[derive(Debug)]
struct Foo {
    bar: HashMap,
}
```

# Snippet B:

```rust
let foo = Foo {
    bar: {
        let mut result = HashMap::new();
        result.insert("answer".to_owned(), 42);
        result
    },
};

println!("{:?}", foo);
```

Of course this readme file was baked too, you can see template sources in /examples folder! So to see how to escape MD Bakery code blocks go there and look it up yourself :D

Usage:

md-bakery 1.0.0
Patryk 'PsichiX' Budzynski <[email protected]>
Markdown Bakery CLI app

USAGE:
    mdbakery.exe [OPTIONS] --input <FILE> --output <FILE>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -i, --input <FILE>     Markdown template file name
    -o, --output <FILE>    Markdown generated file name
    -r, --root <FILE>      Source files root path

TODO:

  • Add exec code block variant that runs executable with parameters specified in block content, then put its stdout:

    ```bash: exec
    cargo run -- --help
    ```
    
You might also like...
CLI tool to find duplicate files based on their hashes.

Dupper Dupper is a CLI tool that helps you identify duplicate files based on their hashes (using the Seahash hashing algorithm). Installation You can

CLI tool to convert image files.

🐟 F1sh CLI tool to convert image files. 🖼️ Supported formats File Supported AviF ✅ BMP ✅ DDS ✅ Farbfeld ✅ GIF ✅ HEIF ❌ ICO ✅ JPEG ✅ OpenEXR ✅ PNG ✅

tpp (Tera Pre-Processor) is a versatile CLI (Command Line Interface) tool crafted for preprocessing files using the Tera templating engine.

tpp (Tera Pre-Processor) is a versatile CLI (Command Line Interface) tool crafted for preprocessing files using the Tera templating engine. Drawing inspiration from pre-processors like cpp and gpp, tpp is the next evolution with its powerful expressive toolset.

A Yocto setup and management tool that helps you keep your environment up-to-date and in-sync with your team
A Yocto setup and management tool that helps you keep your environment up-to-date and in-sync with your team

yb (Yocto Buddy) yb is designed to make it easy to setup and (perhaps more importantly) keep Yocto environments up-to-date and in-sync with your team.

A CLI tool which can help you automatically kill process of your choice. Useful for freeing up memory and CPU usage!
A CLI tool which can help you automatically kill process of your choice. Useful for freeing up memory and CPU usage!

Quickiller There are always programs such as chrome that keep eating up your resources even when closed! The only way to prevent this is to kill all o

A CLI companion tool for paste.misterio.me, allowing you to easily upload and manage your pastes

This is a CLI companion tool for paste.misterio.me, allowing you to easily upload and manage your pastes, as well as download any pastes you want.

Sleek is a CLI tool for formatting SQL. It helps you maintain a consistent style across your SQL code, enhancing readability and productivity.

Sleek: SQL Formatter ✨ Sleek is a CLI tool for formatting SQL. It helps you maintain a consistent style across your SQL code, enhancing readability an

A CLI tool to get help with CLI tools 🐙
A CLI tool to get help with CLI tools 🐙

A CLI tool to get help with CLI tools 🐙 halp aims to help find the correct arguments for command-line tools by checking the predefined list of common

 This CLI utility facilitates effortless manipulation and exploration of TOML, YAML, JSON and RON files.
This CLI utility facilitates effortless manipulation and exploration of TOML, YAML, JSON and RON files.

📁💻🔍🔧 This CLI utility facilitates effortless manipulation and exploration of TOML, YAML, JSON and RON files.

Comments
  • Automatic indentation removal

    Automatic indentation removal

    Great project. I'm adopting it right now, and I have one suggestion for a feature. When using snippets that are completely indented, ie:

    {
        // [md-bakery: begin @ snippet-b]
        let db =
            Storage::<Shape>::open_local("view-examples.pliantdb", &Configuration::default()).await?;
        // [md-bakery: end]
    }
    

    The baked markdown includes the preceding whitespace on the lines. I would prefer if it stripped identical whitespace when it's present on all of the snippet lines.

    opened by ecton 5
Owner
Patryk Budzyński
Patryk Budzyński
CLI Tool for tagging and organizing files by tags.

wutag ?? ??️ CLI tool for tagging and organizing files by tags. Install If you use arch Linux and have AUR repositories set up you can use your favour

Wojciech Kępka 32 Dec 6, 2022
miniserve - a CLI tool to serve files and dirs over HTTP

?? For when you really just want to serve some files over HTTP right now!

Sven-Hendrik Haase 4.1k Jan 6, 2023
Voila is a domain-specific language launched through CLI tool for operating with files and directories in massive amounts in a fast & reliable way.

Voila is a domain-specific language designed for doing complex operations to folders & files. It is based on a CLI tool, although you can write your V

Guillem Jara 86 Dec 12, 2022
A filesystem driver that allows you to view your Blackboard course contents as if they were normal files and folders on your system!

BlackboardFS Blackboard: noun A website so bad that it might as well be a network drive. BlackboardFS is a filesystem driver that allows you to view y

null 22 Sep 4, 2023
BoilerFiles is a CLI for downloading your boilerplate files from a public GitHub template repo.

BoilerFiles Available on crates.io. BoilerFiles is a CLI for downloading your boilerplate files from a public GitHub template repo. Features Are you t

Jan Müller 4 Oct 1, 2022
A Rust based simple cli to delete all files included in `.gitignore` file from your repo

clean-local A simple CLI to remove all the files and folders included in the .gitignore file. Written in RUST Supports glob and wildcard paths in .git

Vilva Athiban P B 5 Jul 8, 2023
A cli tool to download specific GitHub directories or files

cloneit A cli tool to download specific GitHub directories or files. Installation From git git clone https://github.com/alok8bb/cloneit cd cloneit car

Alok 54 Dec 20, 2022
A CLI tool to rename files to randomly generated strings.

rng-rename A CLI tool to rename files to randomly generated strings. Why? Suppose you downloaded a few hundred images to use as your desktop wallpaper

null 2 Feb 24, 2022
A CLI tool used for rendering Blender files to a cropped spritesheet

BuilderGenerator A CLI tool used for rendering Blender files to a cropped spritesheet Clients Rust

Eric Olson 1 Feb 18, 2022
'apk-yara-checker' is a little CLI tool written in Rust to check Yara rules against a folder of APK files.

apk-yara-checker 'apk-yara-checker' is a little CLI tool written in Rust to check Yara rules against a folder of APK files. You have to pass the folde

alberto__segura 15 Oct 5, 2022