Skip to main content

Manipulate YAML front matter.

Project description

py-frontmatter

Hatch project formatter 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.0a5.tar.gz (32.2 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.0a5-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py_frontmatter-0.5.0a5.tar.gz
Algorithm Hash digest
SHA256 001bdfb7e538959dc78d1f069983ed0adf055f821cf88e0d843ccae4090c3b1d
MD5 03220d1f84b3e1b4d2dcbdeb15762bfb
BLAKE2b-256 976f8621282b3740289023aecff271a86a25df56a46b551fcdb01c950f4ebd38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_frontmatter-0.5.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 7ac04ff1afce6fb36be591722ff5f091f84e5bebfd7e98ccaa4c7e68a7adb273
MD5 b94b93ee5f37b9a2f64a763c3f39fe83
BLAKE2b-256 8b9c137da80409da957e475a5945b3ca8e2c369205f87083d1b1989a1a94f64f

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