slackformat


Nameslackformat JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryA utility for converting between Slack's formats.
upload_time2025-08-11 02:48:47
maintainerNone
docs_urlNone
authorSam Begin
requires_python>=3.9
licenseNone
keywords slack markdown block-kit rich-text converter
VCS
bugtrack_url
requirements pytest pytest-cov
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SlackFormat

[![CI](https://github.com/sbegin0/SlackFormat/actions/workflows/tests.yml/badge.svg)](https://github.com/sbegin0/SlackFormat/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/sbegin0/SlackFormat/branch/main/graph/badge.svg)](https://codecov.io/gh/sbegin0/SlackFormat)

**SlackFormat** is a Python library that enables easy manipulation of Slack messages in any format. It provides a simple and intuitive way to convert between Slack's Markdown, Rich Text, and Block Kit formats.

-----

## Features

  * **Markdown to Rich Text:** Convert Slack's Markdown to a Rich Text object.
  * **Rich Text to Block Kit:** Convert a Rich Text object to a Block Kit JSON structure.
  * **Block Kit to Rich Text:** Convert Block Kit JSON to a Rich Text object.
  * **Block Kit to Markdown:** Convert Block Kit JSON to a Markdown string.
  * **Rich Text to Markdown:** Convert a Rich Text object to a Markdown string.
  * **Markdown to Block Kit:** A convenience function to convert a Markdown string directly to a Block Kit object.
  * **Comprehensive Formatting Support:** Supports various formatting options including bold, italic, strikethrough, code, links, and lists.

-----

## Installation

To install the library, you can use `pip`: (hopefully soon lol -- sorry to get ur hopes up)

```bash
pip install slackformat
```

-----

## Usage

Here are some examples of how to use the **SlackFormat** library.

### Markdown to Rich Text

You can convert a Markdown string to a Slack Rich Text object.

```python
from slackformat import md_to_richtext

md = "Hello *bold* and _italic_ text"
richtext = md_to_richtext(md)
print(richtext)
```

### Rich Text to Block Kit

You can convert a Rich Text object to a Block Kit JSON structure.

```python
from slackformat import richtext_to_blockkit

richtext = {
    "type": "rich_text_section",
    "elements": [
        {"type": "text", "text": "Hello "},
        {"type": "text", "text": "world", "style": {"bold": True}}
    ]
}
blockkit = richtext_to_blockkit(richtext)
print(blockkit)
```

### Block Kit to Rich Text

You can convert a Block Kit JSON structure to a Rich Text object.

```python
from slackformat import blockkit_to_richtext

blockkit = {
    "type": "section",
    "text": {"type": "mrkdwn", "text": "*Bold* text"}
}
richtext = blockkit_to_richtext(blockkit)
print(richtext)
```

### Block Kit to Markdown

You can convert a Block Kit JSON structure to a Markdown string.

```python
from slackformat import blockkit_to_markdown

blockkit = {
    "type": "section",
    "text": {"type": "mrkdwn", "text": "*Bold* text"}
}
markdown = blockkit_to_markdown(blockkit)
print(markdown)
```

### Rich Text to Markdown

You can convert a Rich Text object to a Markdown string.

```python
from slackformat import richtext_to_markdown

richtext = {
    "type": "rich_text_section",
    "elements": [
        {"type": "text", "text": "Hello "},
        {"type": "text", "text": "world", "style": {"bold": True}}
    ]
}
markdown = richtext_to_markdown(richtext)
print(markdown)
```

### Markdown to Block Kit

You can convert a Markdown string directly to a Block Kit object.

```python
from slackformat import md_to_blockkit

md = "Hello *bold* and _italic_ text"
blockkit = md_to_blockkit(md)
print(blockkit)
```

-----

## Testing

To run the tests for this library, you can use `pytest`.

```bash
python -m pytest
```

With coverage reporting (requires `pytest-cov`):

```bash
pytest --cov=slackformat --cov-report=term-missing --cov-report=xml
```

The tests cover the following:

  * **Markdown to Rich Text Converter** (`tests/converters/test_md_to_richtext.py`)
  * **Rich Text to Block Kit Converter** (`tests/converters/test_richtext_to_blockkit.py`)
  * **Block Kit to Rich Text Converter** (`tests/converters/test_blockkit_to_richtext.py`)
  * **Block Kit to Markdown Converter** (`tests/converters/test_blockkit_to_md.py`)
  * **Rich Text to Markdown Converter** (`tests/converters/test_richtext_to_md.py`)
  * **Markdown to Block Kit Converter** (`tests/converters/test_md_to_blockkit.py`)
  * **Integration Tests** (`tests/test_integration.py`)

-----

## License

This project is licensed under the Apache License 2.0.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "slackformat",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "slack, markdown, block-kit, rich-text, converter",
    "author": "Sam Begin",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2b/86/21bac87bf9b4ba77760a2eede94846e6e7a493c8700bf28b959fa94ceff9/slackformat-1.0.0.tar.gz",
    "platform": null,
    "description": "# SlackFormat\n\n[![CI](https://github.com/sbegin0/SlackFormat/actions/workflows/tests.yml/badge.svg)](https://github.com/sbegin0/SlackFormat/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/sbegin0/SlackFormat/branch/main/graph/badge.svg)](https://codecov.io/gh/sbegin0/SlackFormat)\n\n**SlackFormat** is a Python library that enables easy manipulation of Slack messages in any format. It provides a simple and intuitive way to convert between Slack's Markdown, Rich Text, and Block Kit formats.\n\n-----\n\n## Features\n\n  * **Markdown to Rich Text:** Convert Slack's Markdown to a Rich Text object.\n  * **Rich Text to Block Kit:** Convert a Rich Text object to a Block Kit JSON structure.\n  * **Block Kit to Rich Text:** Convert Block Kit JSON to a Rich Text object.\n  * **Block Kit to Markdown:** Convert Block Kit JSON to a Markdown string.\n  * **Rich Text to Markdown:** Convert a Rich Text object to a Markdown string.\n  * **Markdown to Block Kit:** A convenience function to convert a Markdown string directly to a Block Kit object.\n  * **Comprehensive Formatting Support:** Supports various formatting options including bold, italic, strikethrough, code, links, and lists.\n\n-----\n\n## Installation\n\nTo install the library, you can use `pip`: (hopefully soon lol -- sorry to get ur hopes up)\n\n```bash\npip install slackformat\n```\n\n-----\n\n## Usage\n\nHere are some examples of how to use the **SlackFormat** library.\n\n### Markdown to Rich Text\n\nYou can convert a Markdown string to a Slack Rich Text object.\n\n```python\nfrom slackformat import md_to_richtext\n\nmd = \"Hello *bold* and _italic_ text\"\nrichtext = md_to_richtext(md)\nprint(richtext)\n```\n\n### Rich Text to Block Kit\n\nYou can convert a Rich Text object to a Block Kit JSON structure.\n\n```python\nfrom slackformat import richtext_to_blockkit\n\nrichtext = {\n    \"type\": \"rich_text_section\",\n    \"elements\": [\n        {\"type\": \"text\", \"text\": \"Hello \"},\n        {\"type\": \"text\", \"text\": \"world\", \"style\": {\"bold\": True}}\n    ]\n}\nblockkit = richtext_to_blockkit(richtext)\nprint(blockkit)\n```\n\n### Block Kit to Rich Text\n\nYou can convert a Block Kit JSON structure to a Rich Text object.\n\n```python\nfrom slackformat import blockkit_to_richtext\n\nblockkit = {\n    \"type\": \"section\",\n    \"text\": {\"type\": \"mrkdwn\", \"text\": \"*Bold* text\"}\n}\nrichtext = blockkit_to_richtext(blockkit)\nprint(richtext)\n```\n\n### Block Kit to Markdown\n\nYou can convert a Block Kit JSON structure to a Markdown string.\n\n```python\nfrom slackformat import blockkit_to_markdown\n\nblockkit = {\n    \"type\": \"section\",\n    \"text\": {\"type\": \"mrkdwn\", \"text\": \"*Bold* text\"}\n}\nmarkdown = blockkit_to_markdown(blockkit)\nprint(markdown)\n```\n\n### Rich Text to Markdown\n\nYou can convert a Rich Text object to a Markdown string.\n\n```python\nfrom slackformat import richtext_to_markdown\n\nrichtext = {\n    \"type\": \"rich_text_section\",\n    \"elements\": [\n        {\"type\": \"text\", \"text\": \"Hello \"},\n        {\"type\": \"text\", \"text\": \"world\", \"style\": {\"bold\": True}}\n    ]\n}\nmarkdown = richtext_to_markdown(richtext)\nprint(markdown)\n```\n\n### Markdown to Block Kit\n\nYou can convert a Markdown string directly to a Block Kit object.\n\n```python\nfrom slackformat import md_to_blockkit\n\nmd = \"Hello *bold* and _italic_ text\"\nblockkit = md_to_blockkit(md)\nprint(blockkit)\n```\n\n-----\n\n## Testing\n\nTo run the tests for this library, you can use `pytest`.\n\n```bash\npython -m pytest\n```\n\nWith coverage reporting (requires `pytest-cov`):\n\n```bash\npytest --cov=slackformat --cov-report=term-missing --cov-report=xml\n```\n\nThe tests cover the following:\n\n  * **Markdown to Rich Text Converter** (`tests/converters/test_md_to_richtext.py`)\n  * **Rich Text to Block Kit Converter** (`tests/converters/test_richtext_to_blockkit.py`)\n  * **Block Kit to Rich Text Converter** (`tests/converters/test_blockkit_to_richtext.py`)\n  * **Block Kit to Markdown Converter** (`tests/converters/test_blockkit_to_md.py`)\n  * **Rich Text to Markdown Converter** (`tests/converters/test_richtext_to_md.py`)\n  * **Markdown to Block Kit Converter** (`tests/converters/test_md_to_blockkit.py`)\n  * **Integration Tests** (`tests/test_integration.py`)\n\n-----\n\n## License\n\nThis project is licensed under the Apache License 2.0.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A utility for converting between Slack's formats.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/sbegin0/SlackFormat",
        "Issues": "https://github.com/sbegin0/SlackFormat/issues",
        "Repository": "https://github.com/sbegin0/SlackFormat"
    },
    "split_keywords": [
        "slack",
        " markdown",
        " block-kit",
        " rich-text",
        " converter"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "250ea3ecff99b430de804e17f0d5833fc5eac12c341b73c23f90b3a5f1941f1d",
                "md5": "52eb572be0bc4e3b19711f6d438e7c75",
                "sha256": "9c2ea0cd046f691e22f3223ab18a703c3cb91ab498eef6e1d165f469526ce5af"
            },
            "downloads": -1,
            "filename": "slackformat-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "52eb572be0bc4e3b19711f6d438e7c75",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 18578,
            "upload_time": "2025-08-11T02:48:46",
            "upload_time_iso_8601": "2025-08-11T02:48:46.552208Z",
            "url": "https://files.pythonhosted.org/packages/25/0e/a3ecff99b430de804e17f0d5833fc5eac12c341b73c23f90b3a5f1941f1d/slackformat-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2b8621bac87bf9b4ba77760a2eede94846e6e7a493c8700bf28b959fa94ceff9",
                "md5": "2dc4dad6fbe68acad693ddf6d25ffb1a",
                "sha256": "ce83a83448a8e9bd08780f7a3e4456415ca9a2ce1c9eaa7686364120b13c8db0"
            },
            "downloads": -1,
            "filename": "slackformat-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2dc4dad6fbe68acad693ddf6d25ffb1a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 14740,
            "upload_time": "2025-08-11T02:48:47",
            "upload_time_iso_8601": "2025-08-11T02:48:47.974084Z",
            "url": "https://files.pythonhosted.org/packages/2b/86/21bac87bf9b4ba77760a2eede94846e6e7a493c8700bf28b959fa94ceff9/slackformat-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-11 02:48:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sbegin0",
    "github_project": "SlackFormat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "pytest-cov",
            "specs": []
        }
    ],
    "lcname": "slackformat"
}
        
Elapsed time: 1.75659s