feat: Complete Issue #38 TDD8 Cycle 1 - Content command family implementation

Implemented comprehensive content command family for MarkdownMatters CLI following TDD8 methodology and MarkdownMatters specification.

## TDD8 Cycle 1 - Content Commands

### Core Implementation
- Content parser for extracting main content without matter zones
- Content statistics calculator (words, lines, paragraphs, characters)
- CLI commands: `content-get` and `content-stats`
- Full integration with existing markitect CLI

### MarkdownMatters Compliance
- Correctly removes YAML/TOML/JSON frontmatter
- Correctly removes tailmatter blocks (`yaml tailmatter`, `json tailmatter`)
- Preserves contentmatter (MultiMarkdown key-value pairs within content)
- Follows three-zone specification from wiki/MarkdownMatters.md

### Module Structure
```
markitect/content/
├── __init__.py          # Module exports
├── parser.py           # ContentParser with matter zone removal
├── stats.py            # ContentStats data class
└── commands.py         # CLI commands implementation
```

### CLI Commands Added
- `markitect content-get --file [path]` - Extract pure content
- `markitect content-stats --file [path]` - Calculate content statistics

### Test Coverage
- 16 comprehensive tests covering all scenarios
- Test fixtures for different document types
- CLI integration tests with Click testing
- Edge case handling (file not found, empty content, etc.)

### Validation Results
- All tests pass (16/16)
- Manual CLI testing confirmed
- Proper matter zone separation validated
- Statistics calculation accuracy verified

## Technical Architecture

### ContentParser Class
- `extract_content()` - Remove frontmatter and tailmatter
- `calculate_stats()` - Generate comprehensive statistics
- `_remove_frontmatter()` - YAML frontmatter removal
- `_remove_tailmatter()` - Tailmatter block removal

### ContentStats Data Class
- word_count, line_count, paragraph_count, character_count
- JSON serialization support via `to_dict()`

## GAMEPLAN Progress
-  TDD8 Cycle 1: Content Commands (COMPLETE)
- 🔄 Next: Cycle 2 - Frontmatter Commands
- Remaining: Contentmatter, Tailmatter command families

This implements the foundation for Issue #38 with 6 remaining cycles planned for complete MarkdownMatters CLI functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-02 08:14:38 +02:00
parent 30e164a87b
commit 246decbcac
11 changed files with 596 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
---
title: "Complete Test Document"
author: "Test Author"
date: 2025-10-02
tags: ["test", "markdown", "matters"]
---
# Complete Test Document
This is the main content of the document. It contains multiple paragraphs and various elements to test content extraction.
Author: John Doe
Project: MarkdownMatters Implementation
Status: In Progress
## Section 1
Here is some content in the first section. This paragraph contains exactly twenty-five words to help with word counting tests.
## Section 2
Another section with different content. This helps test paragraph counting and ensures that the content parser works correctly across multiple sections.
The final paragraph of the main content area.
---
```yaml tailmatter
qa_checklist:
- requirement: "All headers verified"
complete: true
- requirement: "Links checked"
complete: false
editorial:
status: "In Review"
reviewer: "jane.doe"
version: 1.2
agent_config:
role: "documentation_reviewer"
access_scope: "content"
```

View File

@@ -0,0 +1,21 @@
# Document with Contentmatter
This document contains MultiMarkdown key-value pairs within the content body.
Author: Jane Smith
Project: Content Testing
Keywords: markdown, contentmatter, testing
## Introduction
This section demonstrates contentmatter usage. The key-value pairs above are part of the content but provide metadata.
Reference: https://example.com/docs
Version: 2.1
License: MIT
The content continues here with more text for testing purposes. This paragraph helps verify that contentmatter is preserved in content extraction.
## Conclusion
Final section with summary content. Word counting should include the contentmatter lines as part of the content.

View File

@@ -0,0 +1,15 @@
---
title: "Frontmatter Only Document"
author: "Test Author"
date: 2025-10-02
---
# Frontmatter Only Document
This document only has frontmatter, no tailmatter. The content should be extracted without the frontmatter block.
This is a simple paragraph for testing. It has exactly twelve words for counting purposes.
## Simple Section
Another paragraph here. This helps test the content extraction when only frontmatter is present.

View File

@@ -0,0 +1,13 @@
# Plain Markdown Document
This is a simple markdown document without any frontmatter or tailmatter. Just pure content.
This paragraph contains exactly fifteen words for testing the word counting functionality of the parser.
## Section One
Another section with regular content. This helps test the basic content extraction without any matter zones.
## Section Two
The final section with some more content. Multiple paragraphs help test paragraph counting and line counting features.

View File

@@ -0,0 +1,19 @@
# Tailmatter Only Document
This document only has tailmatter, no frontmatter. The content should be extracted without the tailmatter block.
This is a test paragraph. It contains exactly ten words for counting purposes.
Another paragraph for testing content extraction with tailmatter present but no frontmatter.
---
```yaml tailmatter
qa_checklist:
- requirement: "Document structure validated"
complete: true
editorial:
status: "Draft"
reviewer: "test.reviewer"
```