from plantweb import render | |
import re | |
def sanitize_plantuml_code(plantuml_code): | |
match = re.search(r'```plantuml\s*(.*?)\s*```', plantuml_code, re.DOTALL) | |
if match: | |
return match.group(1).strip() | |
return "@startuml\n'Error\n@enduml" | |
def render_plantuml(plantuml_code): | |
try: | |
svg_output, _, _, _ = render.render(plantuml_code, engine='plantuml', format='svg') | |
return svg_output.decode('utf-8') | |
except Exception as e: | |
return f"Error rendering PlantUML: {e}" |