Name | mdfy JSON |
Version |
0.3.0
JSON |
| download |
home_page | https://github.com/argonism/mdfy |
Summary | Transform text into beautiful markdown, effortlessly. |
upload_time | 2023-10-08 16:14:49 |
maintainer | |
docs_url | None |
author | k-ush |
requires_python | >=3.8,<4.0 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center">
<br/>
<br/>
<picture>
<img alt="mdfy teaser" src="https://raw.githubusercontent.com/argonism/mdfy/main/teaser.png" style="max-width: 100%;">
</picture>
</p>
<p align="center">
<img alt="test" src="https://img.shields.io/github/actions/workflow/status/argonism/mdfy/test_for_pr.yml?logo=pytest&label=test&color=green">
<img alt="latest version" src="https://img.shields.io/github/v/tag/argonism/mdfy?logo=pypi&logoColor=white&label=latest%20version">
<img alt="issues" src="https://img.shields.io/github/issues/argonism/mdfy">
<a href='https://mdfy.readthedocs.io/en/latest/?badge=latest'>
<img src='https://readthedocs.org/projects/mdfy/badge/?version=latest' alt='Documentation Status' />
</a>
<img alt="PyPI dialy downloads" src="https://img.shields.io/pypi/dd/mdfy">
<img alt="PyPI weekly downloads" src="https://img.shields.io/pypi/dw/mdfy">
<img alt="PyPI monthly downloads" src="https://img.shields.io/pypi/dm/mdfy">
</p>
# mdfy
Transform text into beautiful markdown, effortlessly.
<!-- <p align="center">
<img src="path_to_your_project_logo_or_image" alt="MDFY Logo" width="400">
</p> -->
## 🌟 Features
- **Simplicity**: Just a few lines of code and voila! An intuitive architecture made simple.
- **Modulability**: Each module is highly independent, making it easy to use on its own.
- **Customizable**: Extensible design allowing for easy customization.
- **Highly Tested**: Robust unit tests ensure reliability.
## 🚀 Getting Started
### Installation
```shell
pip install mdfy
```
### Usage
Here's a quick start guide to get you up and running!
```python
from mdfy import Mdfier, MdText, MdHeader, MdTable
contents = [
MdHeader("Hello, MDFY!"),
MdText("[Life:bold] is [like:italic] a bicycle."),
MdTable(["head1": "content", "head2": "content"])
]
Mdfier("markdown.md").write(contents)
# or use a with statement to write iteratively
with Mdfier("markdown.md") as md:
for content in contents:
md.write(MdText(text))
# => markdown.md
#
# # Hello, MDFY!
# **Life** is *like* a bicycle.
```
Each mdfy element is string-convertible and can operate independently!
```python
from mdfy import MdText, MdHeader, MdTable
print(MdHeader("Hello, MDFY!"))
print(MdText("[Life:bold] is [like:italic] a bicycle."))
print(MdTable(["head1": "content", "head2": "content"]))
# => result
#
# # Hello, MDFY!
# **Life** is *like* a bicycle.
# | head1 | head2 |
# | --- | --- |
# | content | content |
```
## MdText Format
With MdText, you can flexibly specify text styles in a way similar to python's string formatting.
```python
MdText("[a family:quote] of [plain-text formatting syntaxes:bold] that optionally can be [converted to [formal:italic] [markup languages:bold]:not] such as [HTML:strong]")
```
`a family` of **plain-text formatting syntaxes** that optionally can be ~~converted to _formal_ **markup languages**~~ such as **_HTML_**
See [MdText document](https://mdfy.readthedocs.io/en/latest/mdfy.elements.text.html#mdfy.elements.text.MdText) for details
## MdTable
MdTable offers a flexible way to convert a Python dict to a Markdown table.
```python
data = [
{"precision": 0.845, "Recall": 0.662},
{"precision": 0.637, "Recall": 0.802},
{"precision": 0.710, "Recall": 0.680},
]
print(MdTable(data))
# The result will be
# | precision | Recall |
# | --- | --- |
# | 0.845 | 0.662 |
# | 0.637 | 0.802 |
# | 0.71 | 0.68 |
```
To transpose a table, all you need to do is pass True to the transpose parameter.
```python
print(MdTable(data, transpose=True))
# | Key | Value 0 | Value 1 | Value 2 |
# | --- | --- | --- | --- |
# | precision | 0.845 | 0.637 | 0.71 |
# | Recall | 0.662 | 0.802 | 0.68 |
# And you can specify header labels when transpose
labels = ["Metrics", "Model 1", "Model 2", "Model 3"]
print(MdTable(data, transpose=True, labels=labels))
# | Metrics | Model 1 | Model 2 | Model 3 |
# | --- | --- | --- | --- |
# | precision | 0.845 | 0.637 | 0.71 |
# | Recall | 0.662 | 0.802 | 0.68 |
```
You can also specify the precision of float values.
```python
data = [
{"precision": 0.84544, "Recall": 0.662765},
{"precision": 0.63743, "Recall": 0.802697},
{"precision": 0.718203, "Recall": 0.6802435},
]
labels = ["Metrics", "Model 1", "Model 2", "Model 3"]
print(MdTable(data, transpose=True, labels=labels, precision=3))
# | Metrics | Model 1 | Model 2 | Model 3 |
# | --- | --- | --- | --- |
# | precision | 0.845 | 0.637 | 0.718 |
# | Recall | 0.663 | 0.803 | 0.680 |
```
See [MdTable document](https://mdfy.readthedocs.io/en/latest/mdfy.elements.table.html#mdfy.elements.table.MdTable) for details
## 📖 Documentation
Check out our [full documentation](https://mdfy.readthedocs.io/en/latest/#) for detailed guides and API references.
## ✅ Testing
To run the tests:
```shell
python -m pytest
```
## 💡 Contributing
We welcome contributions!
## 📜 License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/argonism/mdfy",
"name": "mdfy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "k-ush",
"author_email": "argoooooon@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/35/d3/db2e6cae55be9afde0e8371480e5e50c0a92fbd547285d8530f736d9dc29/mdfy-0.3.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <br/>\n <br/>\n <picture>\n <img alt=\"mdfy teaser\" src=\"https://raw.githubusercontent.com/argonism/mdfy/main/teaser.png\" style=\"max-width: 100%;\">\n </picture>\n</p>\n\n<p align=\"center\">\n <img alt=\"test\" src=\"https://img.shields.io/github/actions/workflow/status/argonism/mdfy/test_for_pr.yml?logo=pytest&label=test&color=green\">\n <img alt=\"latest version\" src=\"https://img.shields.io/github/v/tag/argonism/mdfy?logo=pypi&logoColor=white&label=latest%20version\">\n <img alt=\"issues\" src=\"https://img.shields.io/github/issues/argonism/mdfy\">\n <a href='https://mdfy.readthedocs.io/en/latest/?badge=latest'>\n <img src='https://readthedocs.org/projects/mdfy/badge/?version=latest' alt='Documentation Status' />\n </a>\n <img alt=\"PyPI dialy downloads\" src=\"https://img.shields.io/pypi/dd/mdfy\">\n <img alt=\"PyPI weekly downloads\" src=\"https://img.shields.io/pypi/dw/mdfy\">\n <img alt=\"PyPI monthly downloads\" src=\"https://img.shields.io/pypi/dm/mdfy\">\n</p>\n\n# mdfy\n\nTransform text into beautiful markdown, effortlessly.\n\n<!-- <p align=\"center\">\n <img src=\"path_to_your_project_logo_or_image\" alt=\"MDFY Logo\" width=\"400\">\n</p> -->\n\n## \ud83c\udf1f Features\n\n- **Simplicity**: Just a few lines of code and voila! An intuitive architecture made simple.\n- **Modulability**: Each module is highly independent, making it easy to use on its own.\n- **Customizable**: Extensible design allowing for easy customization.\n- **Highly Tested**: Robust unit tests ensure reliability.\n\n## \ud83d\ude80 Getting Started\n\n### Installation\n\n```shell\npip install mdfy\n```\n\n### Usage\n\nHere's a quick start guide to get you up and running!\n\n```python\nfrom mdfy import Mdfier, MdText, MdHeader, MdTable\n\ncontents = [\n MdHeader(\"Hello, MDFY!\"),\n MdText(\"[Life:bold] is [like:italic] a bicycle.\"),\n MdTable([\"head1\": \"content\", \"head2\": \"content\"])\n]\nMdfier(\"markdown.md\").write(contents)\n\n# or use a with statement to write iteratively\n\nwith Mdfier(\"markdown.md\") as md:\n for content in contents:\n md.write(MdText(text))\n\n# => markdown.md\n#\n# # Hello, MDFY!\n# **Life** is *like* a bicycle.\n```\n\nEach mdfy element is string-convertible and can operate independently!\n\n```python\nfrom mdfy import MdText, MdHeader, MdTable\n\nprint(MdHeader(\"Hello, MDFY!\"))\nprint(MdText(\"[Life:bold] is [like:italic] a bicycle.\"))\nprint(MdTable([\"head1\": \"content\", \"head2\": \"content\"]))\n\n# => result\n#\n# # Hello, MDFY!\n# **Life** is *like* a bicycle.\n# | head1 | head2 |\n# | --- | --- |\n# | content | content |\n```\n\n## MdText Format\n\nWith MdText, you can flexibly specify text styles in a way similar to python's string formatting.\n\n```python\nMdText(\"[a family:quote] of [plain-text formatting syntaxes:bold] that optionally can be [converted to [formal:italic] [markup languages:bold]:not] such as [HTML:strong]\")\n```\n\n`a family` of **plain-text formatting syntaxes** that optionally can be ~~converted to _formal_ **markup languages**~~ such as **_HTML_**\n\nSee [MdText document](https://mdfy.readthedocs.io/en/latest/mdfy.elements.text.html#mdfy.elements.text.MdText) for details\n\n## MdTable\n\nMdTable offers a flexible way to convert a Python dict to a Markdown table.\n\n```python\ndata = [\n {\"precision\": 0.845, \"Recall\": 0.662},\n {\"precision\": 0.637, \"Recall\": 0.802},\n {\"precision\": 0.710, \"Recall\": 0.680},\n]\n\nprint(MdTable(data))\n\n# The result will be\n# | precision | Recall |\n# | --- | --- |\n# | 0.845 | 0.662 |\n# | 0.637 | 0.802 |\n# | 0.71 | 0.68 |\n```\n\nTo transpose a table, all you need to do is pass True to the transpose parameter.\n\n```python\nprint(MdTable(data, transpose=True))\n\n# | Key | Value 0 | Value 1 | Value 2 |\n# | --- | --- | --- | --- |\n# | precision | 0.845 | 0.637 | 0.71 |\n# | Recall | 0.662 | 0.802 | 0.68 |\n\n# And you can specify header labels when transpose\nlabels = [\"Metrics\", \"Model 1\", \"Model 2\", \"Model 3\"]\nprint(MdTable(data, transpose=True, labels=labels))\n\n# | Metrics | Model 1 | Model 2 | Model 3 |\n# | --- | --- | --- | --- |\n# | precision | 0.845 | 0.637 | 0.71 |\n# | Recall | 0.662 | 0.802 | 0.68 |\n```\n\nYou can also specify the precision of float values.\n\n```python\ndata = [\n {\"precision\": 0.84544, \"Recall\": 0.662765},\n {\"precision\": 0.63743, \"Recall\": 0.802697},\n {\"precision\": 0.718203, \"Recall\": 0.6802435},\n]\nlabels = [\"Metrics\", \"Model 1\", \"Model 2\", \"Model 3\"]\nprint(MdTable(data, transpose=True, labels=labels, precision=3))\n\n# | Metrics | Model 1 | Model 2 | Model 3 |\n# | --- | --- | --- | --- |\n# | precision | 0.845 | 0.637 | 0.718 |\n# | Recall | 0.663 | 0.803 | 0.680 |\n```\n\nSee [MdTable document](https://mdfy.readthedocs.io/en/latest/mdfy.elements.table.html#mdfy.elements.table.MdTable) for details\n\n## \ud83d\udcd6 Documentation\n\nCheck out our [full documentation](https://mdfy.readthedocs.io/en/latest/#) for detailed guides and API references.\n\n## \u2705 Testing\n\nTo run the tests:\n\n```shell\npython -m pytest\n```\n\n## \ud83d\udca1 Contributing\n\nWe welcome contributions!\n\n## \ud83d\udcdc License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Transform text into beautiful markdown, effortlessly.",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/argonism/mdfy",
"Repository": "https://github.com/argonism/mdfy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dbd5cc07185b2f739ccd8656ba4bc30e3920dbc772a063273d06f353103a39df",
"md5": "5c8ff3b03012583364e4bc68725a82e0",
"sha256": "c97c9079fbe9aa0d2cc8cffa135de60ca8c0f1688e12e2838300c9ba068df279"
},
"downloads": -1,
"filename": "mdfy-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5c8ff3b03012583364e4bc68725a82e0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 15097,
"upload_time": "2023-10-08T16:14:47",
"upload_time_iso_8601": "2023-10-08T16:14:47.881882Z",
"url": "https://files.pythonhosted.org/packages/db/d5/cc07185b2f739ccd8656ba4bc30e3920dbc772a063273d06f353103a39df/mdfy-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "35d3db2e6cae55be9afde0e8371480e5e50c0a92fbd547285d8530f736d9dc29",
"md5": "eb7d1aece32d930850cf505eaf4056ec",
"sha256": "9564d97e0bb08bfe72ce1f10c809d2790df16f8464020064cd205de5abeed24b"
},
"downloads": -1,
"filename": "mdfy-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "eb7d1aece32d930850cf505eaf4056ec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 12775,
"upload_time": "2023-10-08T16:14:49",
"upload_time_iso_8601": "2023-10-08T16:14:49.702068Z",
"url": "https://files.pythonhosted.org/packages/35/d3/db2e6cae55be9afde0e8371480e5e50c0a92fbd547285d8530f736d9dc29/mdfy-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-08 16:14:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "argonism",
"github_project": "mdfy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "mdfy"
}