Attempts to repair broken code based on output format. Args: code: The broken code (SVG or mxGraph XML). error_message: The parsing error message. output_format: 'svg' or 'mxgraphxml'. If None, uses CONFIG['OUTPUT_FORMAT']. Returns: The repaired code, o
(code: str, error_message: str, output_format: str = None)
| 904 | |
| 905 | |
| 906 | def repair_code(code: str, error_message: str, output_format: str = None) -> Optional[str]: |
| 907 | """ |
| 908 | Attempts to repair broken code based on output format. |
| 909 | |
| 910 | Args: |
| 911 | code: The broken code (SVG or mxGraph XML). |
| 912 | error_message: The parsing error message. |
| 913 | output_format: 'svg' or 'mxgraphxml'. If None, uses CONFIG['OUTPUT_FORMAT']. |
| 914 | |
| 915 | Returns: |
| 916 | The repaired code, or None after multiple attempts. |
| 917 | """ |
| 918 | output_format = output_format or CONFIG.get('OUTPUT_FORMAT', 'svg') |
| 919 | |
| 920 | if output_format == 'mxgraphxml': |
| 921 | return repair_mxgraphxml(code, error_message) |
| 922 | else: |
| 923 | return repair_svg(code, error_message) |
| 924 | |
| 925 | |
| 926 | def validate_svg_syntax(svg_code: str) -> Tuple[bool, str]: |
no test coverage detected