Coverage for src/prosemark/ports/enhanced_binder_parser.py: 100%
12 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-30 23:09 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-30 23:09 +0000
1"""Enhanced binder parser port interface.
3This module defines the port interface for enhanced binder parsing capabilities
4that preserve extraneous text during binder operations.
5"""
7from abc import ABC, abstractmethod
9from prosemark.domain.models import Binder
10from prosemark.domain.parser_result import ParserResult
13class EnhancedBinderParserPort(ABC):
14 """Port interface for enhanced binder parsing with text preservation.
16 This port extends basic binder parsing capabilities to support preservation
17 of extraneous text during parse and render operations, enabling full
18 round-trip integrity for mixed structural and narrative content.
19 """
21 @abstractmethod
22 def parse_with_preservation(self, markdown_content: str) -> ParserResult:
23 """Parse markdown content preserving all non-structural text.
25 Args:
26 markdown_content: Raw markdown text with mixed structural and narrative content
28 Returns:
29 ParserResult containing binder structure and preserved text
31 Raises:
32 BinderFormatError: If structural parsing fails
34 """
36 @abstractmethod
37 def render_with_preservation(self, parser_result: ParserResult) -> str:
38 """Render ParserResult back to markdown preserving all text positioning.
40 Args:
41 parser_result: Result from parse_with_preservation containing binder and preserved text
43 Returns:
44 Markdown text with structural elements and preserved text
46 """
48 @abstractmethod
49 def parse_to_binder(self, markdown_content: str) -> Binder:
50 """Parse markdown content into a Binder object (legacy method).
52 Args:
53 markdown_content: Markdown text with unordered list structure
55 Returns:
56 Binder object with parsed hierarchy
58 Raises:
59 BinderFormatError: If markdown format is invalid or malformed
61 """
63 @abstractmethod
64 def render_from_binder(self, binder: Binder) -> str:
65 """Render Binder object as markdown list content (legacy method).
67 Args:
68 binder: Binder object to render
70 Returns:
71 Markdown text with unordered list structure
73 """