Manipulate YAML front matter.
Project description
py-frontmatter
To manipulate front matter in document file.
Installation
pip install py-frontmatter
Usage
Given text file:
---
title: Hacker's note
tags: [a, b]
---
# header
text
Get or set whole section of front matter
To retrieve front matter as JSON:
% frontmatter get note.md | jq
{
"title": "Hacker's note",
"tags": [
"a",
"b"
]
}
To replace the front matter:
% echo '{"title": "My note", "tags": ["a", "b", "c"]}' | frontmatter set note.md
% cat note.md
---
title: My note
tags:
- a
- b
- c
---
# header
text
Add or remove item from front matter
% frontmatter add-item --jsonpath '$.tags' --item d note.md
% cat note.md
---
title: My note
tags:
- a
- b
- c
- d
---
# header
text
%
% frontmatter remove-item --jsonpath '$.tags' --item d note.md
% cat note.md
---
title: My note
tags:
- a
- b
- c
---
# header
text
Specialize commands to add/remove tag
% frontmatter add-tag --tag d note.md
% cat note.md
---
title: My note
tags:
- a
- b
- c
- d
---
# header
text
% frontmatter remove-tag --tag d note.md
% cat note.md
---
title: My note
tags:
- a
- b
- c
---
# header
text
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_frontmatter-0.4.0.tar.gz
(10.8 kB
view details)
Built Distribution
File details
Details for the file py_frontmatter-0.4.0.tar.gz
.
File metadata
- Download URL: py_frontmatter-0.4.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d05fa1dc121b45bd86a82f2e407de05e0cdab521eb81ed6cb8ac0279910d97e |
|
MD5 | 744455b0990eba0bd52690adf6028bd5 |
|
BLAKE2b-256 | 9b86cfb937ac4110ee2ee0dc0f16d9245f8a72e82bbbdfa122a1be11aa0e3891 |
File details
Details for the file py_frontmatter-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: py_frontmatter-0.4.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33dce9c1bd97ce67665ae4e4ce5a22a83a7f677b8627a2044fbd8f4faac44fb2 |
|
MD5 | b4410444374adc121382e7f33b6585e7 |
|
BLAKE2b-256 | aa9c810f5606be8c4b72c19d2933184088e42887d7f5da5de8d0680faba024ce |