Giter VIP home page Giter VIP logo

mdfy's Introduction



mdfy teaser

test latest version issues Documentation Status PyPI dialy downloads PyPI weekly downloads PyPI monthly downloads

mdfy

Transform text into beautiful markdown, effortlessly.

๐ŸŒŸ 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

pip install mdfy

Usage

Here's a quick start guide to get you up and running!

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!

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.

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 for details

MdTable

MdTable offers a flexible way to convert a Python dict to a Markdown table.

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.

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.

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 for details

๐Ÿ“– Documentation

Check out our full documentation for detailed guides and API references.

โœ… Testing

To run the tests:

python -m pytest

๐Ÿ’ก Contributing

We welcome contributions!

๐Ÿ“œ License

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

mdfy's People

Contributors

argonism avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.