Skip to content

Instantly share code, notes, and snippets.

@fabiog1901
fabiog1901 / md_numbered_headers.py
Last active December 2, 2025 17:37
Set numbered headers on a markdown file
import sys
counter = [0]
with open(sys.argv[1], "r") as f:
for line in f:
# identify a heading line
if line and line[0:2] == "##":
heading_md, heading_title = line.split(" ", 1)