kt-event-marketing/tools/extract-charts.sh
merrycoral c1f116c821 Mermaid 차트 14개를 개별 .mmd 파일로 추출 완료
- 14개 시장조사 차트를 개별 .mmd 파일로 분리
- 차트 변환 가이드 2종 추가 (README.md, 차트변환가이드.md)
- Mermaid Live Editor 활용 방법 상세 안내
- 프레젠테이션 시나리오별 차트 조합 추천
- 차트 문법 오류 수정 (차트 4번 막대 색상 파란색으로 변경)
- 추출 도구 스크립트 추가 (Python, PowerShell, Bash)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 14:47:01 +09:00

66 lines
1.6 KiB
Bash

#!/bin/bash
# Extract mermaid charts from markdown file
INPUT_FILE="define/시장조사-차트.md"
OUTPUT_DIR="define/charts"
echo "Extracting Mermaid charts from: $INPUT_FILE"
echo "Output directory: $OUTPUT_DIR"
echo ""
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Counter
chart_num=0
# Read file and extract charts
in_mermaid=false
current_chart=""
current_title=""
while IFS= read -r line || [ -n "$line" ]; do
# Check for section header (## number. title)
if [[ $line =~ ^##[[:space:]]([0-9]+)\.[[:space:]](.+)$ ]]; then
num="${BASH_REMATCH[1]}"
title="${BASH_REMATCH[2]}"
current_title=$(printf "chart%02d_%s" "$num" "${title// /_}")
current_title="${current_title//\//_}"
fi
# Check for mermaid start
if [[ $line == '```mermaid' ]]; then
in_mermaid=true
current_chart=""
continue
fi
# Check for mermaid end
if [[ $line == '```' ]] && $in_mermaid; then
# Save chart
if [ -n "$current_title" ]; then
filename="${current_title}.mmd"
echo "$current_chart" > "$OUTPUT_DIR/$filename"
echo " ✓ Saved: $filename"
((chart_num++))
fi
in_mermaid=false
current_chart=""
continue
fi
# Collect chart lines
if $in_mermaid; then
if [ -n "$current_chart" ]; then
current_chart+=$'\n'
fi
current_chart+="$line"
fi
done < "$INPUT_FILE"
echo ""
echo "✅ Successfully extracted $chart_num charts!"
echo ""
echo "Chart files saved in: $OUTPUT_DIR"