MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / validate_code_syntax

Function validate_code_syntax

autofigure/generator.py:1055–1071  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1053
1054
1055def 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
1073def preprocess_svg_for_cairo(svg_code: str) -> str:
1074 import re

Callers 2

generate_initial_codeFunction · 0.85
improve_codeFunction · 0.85

Calls 2

validate_svg_syntaxFunction · 0.85

Tested by

no test coverage detected