mdfy - Transform text into beautiful markdownΒΆ

Test Status Latest Version Downloads

Transform text into beautiful markdown, effortlessly. mdfy provides a simple, intuitive API for creating markdown documents programmatically with Python.

✨ Key Features¢

🎯 Simplicity

Just a few lines of code and voila! An intuitive architecture made simple.

πŸ”§ Modularity

Each module is highly independent, making it easy to use on its own.

🎨 Customizable

Extensible design allowing for easy customization.

βœ… Tested

Robust unit tests ensure reliability.

πŸš€ Quick StartΒΆ

InstallationΒΆ

pip install mdfy

Your First DocumentΒΆ

from mdfy import Mdfier, MdHeader, MdText, MdTable

contents = [
    MdHeader("Hello, MDFY!"),
    MdText("[Life:bold] is [like:italic] a bicycle."),
    MdTable({"head1": "content", "head2": "content"})
]
Mdfier("markdown.md").write(contents)

This creates a markdown file with:

# Hello, MDFY!
**Life** is *like* a bicycle.

| head1 | head2 |
| --- | --- |
| content | content |

Note

New to mdfy? Check out our Getting Started guide for a step-by-step tutorial!

πŸ’‘ Advanced UsageΒΆ

Nested ContentΒΆ

You can pass nested lists to Mdfier.write and they will be flattened:

from mdfy import Mdfier, MdText, MdHeader

group = ["Group A", "Group B"]
group_agg_results = [
    [2, 3, 0, 1],
    [4, 2, 1, 0],
]

contents = [
    MdHeader("Hello, MDFY!"),
    [
        (
            MdHeader(group_name, level=2),
            MdText(f"Sum: {sum(group_agg_result)} ({', '.join(map(str, group_agg_result))})")
        )
        for group_name, group_agg_result in zip(group, group_agg_results)
    ]
]
Mdfier("markdown.md").write(contents)

Independent ElementsΒΆ

Each mdfy element is string-convertible and can operate independently:

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"}))

πŸ“– DocumentationΒΆ

πŸ› οΈ DevelopmentΒΆ

Want to contribute? Great! Here’s how to get started:

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Run tests: python -m pytest

  5. Submit a pull request

πŸ“œ LicenseΒΆ

This project is licensed under the MIT License. See the LICENSE file for details.

Indices and tablesΒΆ