#!/usr/bin/env python3 """ Script to parse epic details markdown and generate a presentation-style website showing all user stories with User Story, Background, and Acceptance Criteria. """ import re from pathlib import Path def parse_epic_details(file_path): """Parse the epic details markdown file and extract stories.""" with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Split by stories story_pattern = r'### Story ([\d.]+): (.+?)\n\n(.*?)(?=\n### Story [\d.]+:|$)' matches = re.findall(story_pattern, content, re.DOTALL) stories = [] for story_num, title, body in matches: # Extract User Story user_story_match = re.search(r'#### User Story\n\n(.*?)(?=\n####|$)', body, re.DOTALL) user_story = user_story_match.group(1).strip() if user_story_match else "Not found" # Extract Background background_match = re.search(r'#### Background\n\n(.*?)(?=\n####|$)', body, re.DOTALL) background = background_match.group(1).strip() if background_match else "Not found" # Extract Acceptance Criteria acceptance_match = re.search(r'#### Acceptance Criteria\n\n(.*?)(?=\n####|$)', body, re.DOTALL) acceptance = acceptance_match.group(1).strip() if acceptance_match else "Not found" # Clean up content user_story = clean_content(user_story) background = clean_content(background) acceptance = clean_content(acceptance) stories.append({ 'number': story_num, 'title': title, 'user_story': user_story, 'background': background, 'acceptance': acceptance }) return stories def clean_content(text): """Clean and escape content for HTML/JS embedding.""" if not text: return "" # Replace problematic characters but preserve meaningful formatting text = text.replace('\\', '\\\\') text = text.replace("'", "\\'") text = text.replace('"', '\\"') text = text.replace('\n', '\\n') return text def generate_html(stories): """Generate the HTML presentation website.""" # Build the HTML structure html_parts = [ '', '', '
', ' ', ' ', '