Skip to main content

Manipulate YAML front matter.

Project description

py-frontmatter

Hatch project Ruff Check

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

License

py-frontmatter is distributed under the terms of the following licenses:

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.5.0a6.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_frontmatter-0.5.0a6-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file py_frontmatter-0.5.0a6.tar.gz.

File metadata

  • Download URL: py_frontmatter-0.5.0a6.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.11

File hashes

Hashes for py_frontmatter-0.5.0a6.tar.gz
Algorithm Hash digest
SHA256 981342375f2fa5f8af3f4b17e8cf8ed9f0ce28a4dd3f1b30f826042ea878b9b4
MD5 a1f7ddf5ec12e3d2eb41f0e26b417827
BLAKE2b-256 ce9096681c53dbe2f3e65b5732436e62bac26c149656756abf028c9483dcdfbf

See more details on using hashes here.

File details

Details for the file py_frontmatter-0.5.0a6-py3-none-any.whl.

File metadata

File hashes

Hashes for py_frontmatter-0.5.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 2efa0e2260a4fe09a3490eed55287dd9c00d09b4a0fb1e16e28fa4aebf8a9de9
MD5 f51cba34e7d3c9f8ead7ae6b4f79ac05
BLAKE2b-256 c951b994605205f0762260062abffb87d5152eee7e79375dc21662aa1038f6e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page