Converts a YAML/JSON file or python Dict/List to a Markdown file
Project description
YAML to Markdown Converter
A Python utility to take a JSON / YAML file or a python dict / list and create a Markdown file.
Installation
pip install yaml-to-markdown
Usage
$ yaml-to-markdown --help
Convert JSON or YAML to Markdown.
Usage: yaml-to-markdown -o <output_file> [-y <yaml_file> | -j <json_file>]
-o, --output-file <output_file>: Path to the output file as a string [Mandatory].
-y, --yaml-file <yaml_file>: Path to the YAML file as a string [Optional]
-j, --json-file <json_file>: Path to the JSON file as a string [Optional]
-h, --help: Show this message and exit.
Note: Either yaml_file or json_file is required along with output_file.
Example: yaml-to-markdown -o output.md -y data.yaml
In Python Code example:
Convert a Pyton dictionary to Markdown:
from yaml_to_markdown.md_converter import MDConverter
data = {
"name": "John Doe",
"age": 30,
"city": "Sydney",
"hobbies": ["reading", "swimming"],
}
converter = MDConverter()
with open("output.md", "w") as f:
converter.convert(data, f)
Content of output.md
file will be:
## Name
John Doe
## Age
30
## City
Sydney
## Hobbies
* reading
* swimming
From the Command Line
You can also use the command line interface to convert a JSON or YAML file to Markdown. Here's an example:
Convert a JSON file to Markdown:
yaml-to-markdown --output-file output.md --json-file test.json
Convert a YAML file to Markdown:
yaml-to-markdown --output-file output.md --yaml-file test.yaml
Developer Guide
Please see the DEVELOPER.md file for more information on how to contribute to this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file yaml_to_markdown-0.1.1725236288.tar.gz
.
File metadata
- Download URL: yaml_to_markdown-0.1.1725236288.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5e548bfcafb916bbab6af63b5e2a35d819f64371b6263ea272c9798f9babe9e |
|
MD5 | a0ed2a8a18e98b0c54c4e54a25fa4a61 |
|
BLAKE2b-256 | 4247f5a6457a38cbec3cc884ea1494fdc134903b259533b6a951f9df3f117b9b |
File details
Details for the file yaml_to_markdown-0.1.1725236288-py3-none-any.whl
.
File metadata
- Download URL: yaml_to_markdown-0.1.1725236288-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3340c3d19d575afa1bf8dc0468dd9e68ce6b6d0aa0b66018fb7fd910f9d2493e |
|
MD5 | cafa88eeb6133d1fce9f7ec23a94a381 |
|
BLAKE2b-256 | 06aacd13a7199db5ac1a9def85c85230ba9037a8bdd32ecf9219c48dceff8315 |