YAML metadata extension for Python-Markdown
Project description
YAML metadata extension for Python-Markdown
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.
Basic Usage
import markdown
text = """---
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) == '<p>Lorem Ipsum is simply dummy text.</p>'
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
using
the extension_configs
keyword argument:
import markdown
import yaml
md = markdown.Markdown(extensions=['full_yaml_metadata']}, extension_configs={
"full_yaml_metadata": {
"yaml_loader": yaml.SafeLoader,
},
},
)
Development and contribution
- install project dependencies
python setup.py develop
- install linting, formatting and testing tools
pip install -r requirements.txt
- run tests
pytest
- run linters
flake8
mypy ./
black --check ./
- feel free to contribute!
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
Close
Hashes for markdown_full_yaml_metadata-2.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9b83c942d35bd68d1acc68546ca6fd24bc82de3f3f342e6d52d1731f2839904 |
|
MD5 | ff3306fa3b25c0203765574f1cbb9e69 |
|
BLAKE2b-256 | 58266f972dea9259ac9c95b0c0cb588ca10f2b0959bc9749e89296b814275330 |
Close
Hashes for markdown_full_yaml_metadata-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e9001fca16e74a9931bf1fb06757c4e1b3ec648f6da65140dd074cf7b8ecf54 |
|
MD5 | 957dd09d17c337543e9c625da56a64fe |
|
BLAKE2b-256 | 70bc1316efb8a459bcb5ea0538246e38cdf260b1aca18abd779784c93342f89e |