#etch

bin+lib etch

Not just a text formatter, don't mark it down, etch it

8 unstable releases (3 breaking)

0.4.2 Dec 21, 2019
0.4.0 Aug 30, 2019
0.3.2 Dec 21, 2019
0.3.0 Jul 11, 2019

#307 in Text processing

Download history 5744/week @ 2022-12-08 3793/week @ 2022-12-15 10/week @ 2022-12-22 221/week @ 2022-12-29 5140/week @ 2023-01-05 317/week @ 2023-01-12 30/week @ 2023-01-19 2000/week @ 2023-01-26 5093/week @ 2023-02-02 5231/week @ 2023-02-09 5317/week @ 2023-02-16 5693/week @ 2023-02-23 5554/week @ 2023-03-02 5645/week @ 2023-03-09 5542/week @ 2023-03-16 5621/week @ 2023-03-23

23,286 downloads per month

MIT license

90KB
2.5K SLoC

Etch v0.4

Not just a text formatter, don't mark it down, etch it.

Syntax

Not too dissimilar from Markdown, simpler yet also more powerful:

# My Document

This is what etch text looks like!

[a]
You can tag entire blocks of text with a tag prefix, individual words[b]
with a tag suffix, or [entire spans of text][b] using square brackets.

#[a: .myClass]
#[b: @alt surprise alt text!]
#[c: @https://example.com]

And lastly, tags can be declared when you first reference them[d: .nice]
and the tag name is optional[.cool].

Documents can import other documents:

#import[my-document.etch]

Or other files as preformatted text:

[css]
#import[my-css-example.css]

Documents can contain custom metadata such as a title or description:

#meta[title: My Document]

Plugin API allows for transforming documents or injecting custom parsers.

use etch::Etch;
use etch::plugins::*;

let word_count = WordCountPlugin::new();
let etch = Etch::default()
    .with_plugin(word_count.clone())
    .with_document("my_document.etch");

println!("{:#?}", word_count);

Code syntax highlighting provided by the Syntect plugin.

Enable the syntect-plugin feature:

[dependencies]
etch = { version = "...", features = ["syntect-plugin"] }

And attach the plugin:

use etch::Etch;
use etch::plugins::*;

let etch = Etch::default()
    .with_plugin(SyntectPlugin::new())
    .with_document("my_document.etch");

Usage

use etch::Etch;
use etch::plugins::*;

fn main() {
    let metadata = MetadataPlugin::new();
    let word_count = WordCountPlugin::new();
    let etch = Etch::default()
        .with_plugin(metadata.clone())
        .with_plugin(word_count.clone())
        .with_plugin(SyntectPlugin::new())
        .with_plugin(WidowedWordsPlugin::new())
        .with_document("my_document.etch");

    println!("{:#?}", etch.render());
    println!("{:#?}", metadata);
    println!("{:#?}", word_count);
}

Dependencies

~0.8–1.8MB
~39K SLoC