{"id":34023654,"url":"https://github.com/ergut/md-hierarchy","last_synced_at":"2026-04-05T11:32:44.235Z","repository":{"id":318933450,"uuid":"1077014063","full_name":"ergut/md-hierarchy","owner":"ergut","description":"Transform large markdown files into hierarchical folder structures for better navigation and AI-assisted editing.","archived":false,"fork":false,"pushed_at":"2025-10-17T11:29:23.000Z","size":1538,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-15T05:24:08.189Z","etag":null,"topics":["cli","command-line-tool","document-management","documentation","file-organization","hierarchy","markdown","markdown-merge","markdown-parser","markdown-split","markdown-tools","static-site-generator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ergut.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-15T16:47:44.000Z","updated_at":"2025-10-17T11:29:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e43b28f-c527-4f44-a5a4-413b596bd300","html_url":"https://github.com/ergut/md-hierarchy","commit_stats":null,"previous_names":["ergut/md-hierarchy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ergut/md-hierarchy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergut%2Fmd-hierarchy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergut%2Fmd-hierarchy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergut%2Fmd-hierarchy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergut%2Fmd-hierarchy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ergut","download_url":"https://codeload.github.com/ergut/md-hierarchy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergut%2Fmd-hierarchy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31434624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line-tool","document-management","documentation","file-organization","hierarchy","markdown","markdown-merge","markdown-parser","markdown-split","markdown-tools","static-site-generator"],"created_at":"2025-12-13T16:01:56.076Z","updated_at":"2026-04-05T11:32:44.206Z","avatar_url":"https://github.com/ergut.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/logo-banner.png\" alt=\"md-hierarchy logo\" width=\"600\"\u003e\n\u003c/p\u003e\n\n# md-hierarchy\n\nA CLI tool that splits markdown files into hierarchical folder structures based on heading levels, and can reconstruct the original markdown from the split pieces.\n\n## Features\n\n- **Split** markdown files into navigable folder hierarchies\n- **Merge** folder structures back into single markdown files\n- Preserves all markdown elements (code blocks, lists, tables, links, etc.)\n- Handles edge cases (duplicate headings, empty headings, skipped levels)\n- Round-trip compatible (split → merge produces equivalent content)\n- Dry-run mode to preview operations\n\n## Installation\n\n```bash\n# From PyPI\npip install md-hierarchy\n\n# From source\npip install -e .\n\n# With development dependencies\npip install -e \".[dev]\"\n```\n\n## Usage\n\n### Split Command\n\nSplit a markdown file into a hierarchical folder structure:\n\n```bash\nmd-hierarchy split input.md output_dir --level 3\n```\n\n**Options:**\n\n- `--level, -l`: Heading level to extract as files (1-4, default: 3)\n- `--overwrite`: Overwrite output directory if it exists\n- `--verbose, -v`: Print detailed operation log\n- `--dry-run`: Show what would be done without writing files\n\n**Example:**\n\n```bash\n# Split at level 3 (H3 headings become files)\nmd-hierarchy split proposal.md ./output --level 3\n\n# Split with overwrite\nmd-hierarchy split proposal.md ./output --level 2 --overwrite\n\n# Preview without creating files\nmd-hierarchy split proposal.md ./output --dry-run\n```\n\n### Merge Command\n\nMerge a folder structure back into a single markdown file:\n\n```bash\nmd-hierarchy merge input_dir output.md\n```\n\n**Options:**\n\n- `--verbose, -v`: Print detailed operation log\n\n**Example:**\n\n```bash\n# Merge folder structure\nmd-hierarchy merge ./output merged.md\n\n# Merge with verbose output\nmd-hierarchy merge ./split-docs final.md --verbose\n```\n\n## Output Structure\n\nWhen splitting at level 3, the tool creates this structure:\n\n```\noutput-dir/\n├── 00-__frontmatter__.md            # Content before first heading (if exists)\n├── 01-Introduction/\n│   ├── 00-__intro__.md              # H1 heading + intro content (always created)\n│   ├── 01-Background/\n│   │   ├── 00-__intro__.md          # H2 heading + intro content (always created)\n│   │   ├── 01-Problem-Statement.md  # H3 section\n│   │   └── 02-Research-Gap.md       # H3 section\n│   └── 02-Objectives/\n│       ├── 00-__intro__.md          # H2 heading (even if no intro content)\n│       └── 01-Primary-Goals.md\n└── 02-Methodology/\n    └── 00-__intro__.md              # H1 heading + content\n```\n\n## File Naming Convention\n\n- **Folders:** `NN-Sanitized-Title/` (e.g., `01-Introduction/`)\n- **Intro files:** `00-__intro__.md` (always created for every heading folder)\n- **Frontmatter:** `00-__frontmatter__.md` (at root, only if content exists before first heading)\n- **Section files:** `NN-Sanitized-Title.md` (e.g., `01-Problem-Statement.md`)\n- Numbers are zero-padded (01, 02, ..., 99)\n- Special characters (`/ \\ : * ? \" \u003c \u003e |`) are removed\n- Spaces are replaced with hyphens\n- Maximum length: 50 characters\n\n### Key Design Decisions\n\n- `00-__intro__.md` is **always created** for every heading folder, even if empty\n  - This provides a consistent structure and an easy place to add intro text later\n  - Contains the heading declaration and any content before child sections\n- The `00-` prefix ensures intro files sort first in directory listings\n- The `__intro__` naming (double underscore) clearly marks these as special/meta files\n- Frontmatter files are created at the root only when pre-heading content exists\n\n## Edge Cases Handled\n\n1. **Empty headings** → `Untitled-Section-N`\n2. **Duplicate titles** → Append `-2`, `-3`, etc.\n3. **Skipped levels** (H1 → H3) → Insert `00-Content/` folder\n4. **Content before first heading** → `00-__frontmatter__.md` at root\n5. **Heading attributes** (e.g., `{#id .class}`) → Preserved in content\n6. **Headings with no intro content** → `00-__intro__.md` still created (with just the heading)\n\n## Round-Trip Compatibility\n\nThe tool is designed for round-trip operations:\n\n```bash\n# Split\nmd-hierarchy split original.md ./split --level 3\n\n# Merge\nmd-hierarchy merge ./split reconstructed.md\n\n# Content should be equivalent\ndiff original.md reconstructed.md\n```\n\n## Development\n\n### Setup\n\n```bash\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # or `venv\\Scripts\\activate` on Windows\n\n# Install in development mode\npip install -e \".[dev]\"\n```\n\n### Run Tests\n\n```bash\npytest\n```\n\n### Run Tests with Coverage\n\n```bash\npytest --cov=md_hierarchy --cov-report=html\n```\n\n## Requirements\n\n- Python 3.8+\n- Dependencies:\n  - `markdown-it-py` - Markdown parsing\n  - `click` - CLI framework\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergut%2Fmd-hierarchy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fergut%2Fmd-hierarchy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergut%2Fmd-hierarchy/lists"}