Skip to main content

py-frontmatter

Code style: black formatter Imports: isort linting: pylint pre-commit pre-commit.ci status

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

Metadata

Release files for py-frontmatter 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-frontmatter 0.4.0
File Size Uploaded
py_frontmatter-0.4.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-frontmatter 0.4.0
File Interpreter ABI Platform
py_frontmatter-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / py_frontmatter-0.4.0.tar.gz

Download URL py_frontmatter-0.4.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7d05fa1dc121b45bd86a82f2e407de05e0cdab521eb81ed6cb8ac0279910d97e
BLAKE2b-256 checksum
How to use checksums
9b86cfb937ac4110ee2ee0dc0f16d9245f8a72e82bbbdfa122a1be11aa0e3891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / py_frontmatter-0.4.0-py3-none-any.whl

Download URL py_frontmatter-0.4.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33dce9c1bd97ce67665ae4e4ce5a22a83a7f677b8627a2044fbd8f4faac44fb2
BLAKE2b-256 checksum
How to use checksums
aa9c810f5606be8c4b72c19d2933184088e42887d7f5da5de8d0680faba024ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page