Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sivakov512/python-markdown-full-yaml-metadata
YAML metadata extension for Python-Markdown
https://github.com/sivakov512/python-markdown-full-yaml-metadata
markdown markdown-extension markdown-metadata metadata python python3 yaml
Last synced: 13 days ago
JSON representation
YAML metadata extension for Python-Markdown
- Host: GitHub
- URL: https://github.com/sivakov512/python-markdown-full-yaml-metadata
- Owner: sivakov512
- License: mit
- Created: 2017-10-17T05:14:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-03T23:00:25.000Z (4 months ago)
- Last Synced: 2024-10-06T07:37:23.889Z (about 1 month ago)
- Topics: markdown, markdown-extension, markdown-metadata, metadata, python, python3, yaml
- Language: Python
- Homepage:
- Size: 55.7 KB
- Stars: 22
- Watchers: 4
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YAML metadata extension for [Python-Markdown](https://github.com/waylan/Python-Markdown)
[![test](https://github.com/sivakov512/python-markdown-full-yaml-metadata/actions/workflows/test.yml/badge.svg)](https://github.com/sivakov512/python-markdown-full-yaml-metadata/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/sivakov512/python-markdown-full-yaml-metadata/badge.svg)](https://coveralls.io/github/sivakov512/python-markdown-full-yaml-metadata)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Python versions](https://img.shields.io/pypi/pyversions/markdown-full-yaml-metadata.svg)](https://pypi.python.org/pypi/markdown-full-yaml-metadata)
[![PyPi](https://img.shields.io/pypi/v/markdown-full-yaml-metadata.svg)](https://pypi.python.org/pypi/markdown-full-yaml-metadata)This extension adds YAML meta data handling to markdown with all YAML features.
As in the original, metadata is parsed but not used in processing.
Metadata parsed as is by PyYaml and without additional transformations, so this plugin is not compatible with original [Meta-Data extension](https://pythonhosted.org/Markdown/extensions/meta_data.html).
## Basic Usage
``` python
import markdowntext = """---
title: What is Lorem Ipsum?
categories:
- Lorem Ipsum
- Stupid content
...Lorem Ipsum is simply dummy text.
"""md = markdown.Markdown(extensions=['full_yaml_metadata']})
md.convert(text) == 'Lorem Ipsum is simply dummy text.
'
md.Meta == {'title': 'What is Lorem Ipsum?', 'categories': ['Lorem Ipsum', 'Stupid content']}
```### Specify a custom YAML loader
By default the full YAML loader is used for parsing, which is insecure when
used with untrusted user data. In such cases, you may want to specify a
different loader such as [`yaml.SafeLoader`](https://msg.pyyaml.org/load) using
the `extension_configs` keyword argument:```python
import markdown
import yamlmd = markdown.Markdown(extensions=['full_yaml_metadata']}, extension_configs={
"full_yaml_metadata": {
"yaml_loader": yaml.SafeLoader,
},
},
)
```## Development and contribution
First of all you should install [Poetry](https://python-poetry.org).
* install project dependencies
```bash
make install
```* run linters
```bash
make lint
```* run tests
```bash
make test
```* feel free to contribute!