Spaces:
Running
Running
Commit ·
0a61b02
1
Parent(s): 2732803
Updated sanitization
Browse files
app.py
CHANGED
|
@@ -38,8 +38,10 @@ app = gr.Server(title="Code-to-Flowchart Generator")
|
|
| 38 |
|
| 39 |
# This is a cleaning function to resolve common syntax errors.
|
| 40 |
def quote_labels(text: str) -> str:
|
| 41 |
-
# Mermaid node labels can't hold raw code
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
def esc(body: str) -> str:
|
| 45 |
return (body.replace('"', "'")
|
|
|
|
| 38 |
|
| 39 |
# This is a cleaning function to resolve common syntax errors.
|
| 40 |
def quote_labels(text: str) -> str:
|
| 41 |
+
# Mermaid node labels can't hold raw code characters, so quote-wrap each label body
|
| 42 |
+
# A label's real closing bracket is followed by a Mermaid connector, edge-label, pipe, statement end, or EOL
|
| 43 |
+
# operators after a subscript (== < <= > >= != %) are never mistaken for a close.
|
| 44 |
+
END = r'(?=\s*(?:[-<][-.>xo]|==[>=xo]|\||;|$))'
|
| 45 |
|
| 46 |
def esc(body: str) -> str:
|
| 47 |
return (body.replace('"', "'")
|