Validates code syntax based on the output format. Args: code: The code to validate (SVG or mxGraph XML). output_format: 'svg' or 'mxgraphxml'. If None, uses CONFIG['OUTPUT_FORMAT']. Returns: Tuple of (is_valid, error_message_or_success_message)
(code: str, output_format: str = None)
| 1053 | |
| 1054 | |
| 1055 | def validate_code_syntax(code: str, output_format: str = None) -> Tuple[bool, str]: |
| 1056 | """ |
| 1057 | Validates code syntax based on the output format. |
| 1058 | |
| 1059 | Args: |
| 1060 | code: The code to validate (SVG or mxGraph XML). |
| 1061 | output_format: 'svg' or 'mxgraphxml'. If None, uses CONFIG['OUTPUT_FORMAT']. |
| 1062 | |
| 1063 | Returns: |
| 1064 | Tuple of (is_valid, error_message_or_success_message) |
| 1065 | """ |
| 1066 | output_format = output_format or CONFIG.get('OUTPUT_FORMAT', 'svg') |
| 1067 | |
| 1068 | if output_format == 'mxgraphxml': |
| 1069 | return validate_mxgraphxml_syntax(code) |
| 1070 | else: |
| 1071 | return validate_svg_syntax(code) |
| 1072 | |
| 1073 | def preprocess_svg_for_cairo(svg_code: str) -> str: |
| 1074 | import re |
no test coverage detected