feat: initial CTStruct framework

- CTNode: 트리 기본 단위 (전위/후위/BFS 순회, 탐색, 분리)
- CTTree: 트리 컨테이너 (빌더 API, TOC, filter/map/merge)
- NodeType: 구조/블록/인라인/메타 노드 타입 Enum
- MarkdownParser: Markdown → CTTree 파서
- MarkdownRenderer: CTTree → Markdown 렌더러
- JSONRenderer: CTTree → JSON 직렬화
- 27개 단위/통합 테스트 전체 통과
This commit is contained in:
2026-05-30 20:40:28 +09:00
commit 6e3cd19b55
38 changed files with 1695 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
"""
ctstruct/renderers/base.py
렌더러 추상 베이스 클래스
"""
from abc import ABC, abstractmethod
from ..tree import CTTree
class BaseRenderer(ABC):
"""
모든 렌더러의 공통 인터페이스.
구현 클래스는 render() 메서드를 오버라이드합니다.
"""
@abstractmethod
def render(self, tree: CTTree) -> str:
"""
CTTree 를 대상 포맷 텍스트로 변환.
Args:
tree: 렌더링할 CTTree
Returns:
변환된 텍스트 문자열
"""
...
def __call__(self, tree: CTTree) -> str:
return self.render(tree)