Rishi-Jain-27 commited on
Commit
0a61b02
·
1 Parent(s): 2732803

Updated sanitization

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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 char, so quote-wrap each label body.
42
- END = r'(?=\s*(?:--|==|-\.|<|\||;|$))'
 
 
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('"', "'")