#slack #markdown #markdown-html #html

slack-blocks-render

Slack blocks render is a Rust library to render Slack blocks as Markdown

2 releases

0.1.1 Jun 10, 2024
0.1.0 Jun 10, 2024

#689 in Text processing

Apache-2.0

43KB
925 lines

slack-blocks-render

Crates.io Version Docs.rs Latest Build Status

Slack blocks render is a Rust library to render Slack blocks as Markdown.

Usage

First, add the slack_blocks_render crate as a dependency:

cargo add slack_blocks_render

Slack blocks render uses the slack_morphism data model as input so you should also add it as a dependency:

cargo add slack_morphism
use slack_morphism::prelude::*;
use slack_blocks_render::render_blocks_as_markdown;

let blocks: Vec<SlackBlock> = vec![
    SlackBlock::RichText(serde_json::json!({
        "type": "rich_text",
        "elements": [
            {
                "type": "rich_text_section",
                "elements": [
                    {
                        "type": "text",
                        "text": "Hello World"
                    }
                ]
            },
        ]
    })),
];
let markdown_text = render_blocks_as_markdown(blocks);

License

This project is distributed under the terms of the Apache License (Version 2.0).

See LICENSE

Dependencies

~9–19MB
~276K SLoC