(svg_code: str)
| 1071 | return validate_svg_syntax(code) |
| 1072 | |
| 1073 | def preprocess_svg_for_cairo(svg_code: str) -> str: |
| 1074 | import re |
| 1075 | |
| 1076 | svg_code = re.sub(r'\s*xmlns:xlink="[^"]*"', '', svg_code) |
| 1077 | svg_code = re.sub(r'\s*xmlns:xml="[^"]*"', '', svg_code) |
| 1078 | |
| 1079 | if 'xmlns="http://www.w3.org/2000/svg"' not in svg_code: |
| 1080 | svg_code = svg_code.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"', 1) |
| 1081 | |
| 1082 | svg_code = re.sub(r'xmlns="http://www\.w3\.org/2000/svg"\s+xmlns="http://www\.w3\.org/2000/svg"', |
| 1083 | 'xmlns="http://www.w3.org/2000/svg"', svg_code) |
| 1084 | |
| 1085 | svg_code = re.sub(r'\s{2,}', ' ', svg_code) |
| 1086 | svg_code = svg_code.strip() |
| 1087 | |
| 1088 | return svg_code |
| 1089 | |
| 1090 | def svg_to_png(svg_code: str, output_path: str, attempt_repair: bool = False) -> Tuple[bool, Optional[str]]: |
| 1091 | try: |
no outgoing calls
no test coverage detected