broadfield-dev commited on
Commit
85f69f9
·
verified ·
1 Parent(s): 9864134

Update app_logic.py

Browse files
Files changed (1) hide show
  1. app_logic.py +6 -37
app_logic.py CHANGED
@@ -63,44 +63,13 @@ def load_token_from_image_and_set_env(image_pil_object: Image.Image, password: s
63
 
64
 
65
  def process_commented_markdown(commented_input):
66
- """Process a commented markdown string by stripping '# ' from lines only if '# # Space:' is detected as the first non-empty line."""
67
- # Strip leading/trailing whitespace and split lines
68
  lines = commented_input.strip().split("\n")
69
-
70
- # Find the first non-empty line to check for '# # Space:'
71
- for line in lines:
72
- if line.strip():
73
- first_non_empty_line = line.strip()
74
- break
75
- else:
76
- return commented_input # No non-empty lines, return unchanged
77
-
78
- # Only process if the first non-empty line is exactly '# # Space: ...'
79
- if not first_non_empty_line.startswith("# # Space:"):
80
- return commented_input # Not a commented space definition, return unchanged
81
-
82
- cleaned_lines = []
83
- in_code_block = False
84
-
85
- for line in lines:
86
- # Detect code block boundaries (handle '# ```' or '```')
87
- if line.strip() in ("# ```", "```"):
88
- in_code_block = not in_code_block
89
- # Preserve backticks, strip '# ' if present
90
- cleaned_line = line.lstrip("# ").rstrip()
91
- cleaned_lines.append(cleaned_line)
92
- continue
93
-
94
- # Strip '# ' from lines that have it
95
- cleaned_line = line.lstrip("# ")
96
-
97
- # In code blocks, remove additional '# ' if present (handles over-commenting, e.g., Gemini)
98
- if in_code_block and cleaned_line.startswith("# "):
99
- cleaned_line = cleaned_line[2:]
100
-
101
- cleaned_lines.append(cleaned_line)
102
-
103
- return "\n".join(cleaned_lines)
104
 
105
 
106
 
 
63
 
64
 
65
  def process_commented_markdown(commented_input):
66
+ """Process a commented markdown string by stripping '# ' from each line if '# # Space:' is present."""
 
67
  lines = commented_input.strip().split("\n")
68
+ # Check for '# # Space:' or variations (e.g., '# Space:') in any line
69
+ if any(line.strip().startswith("# # Space:") for line in lines):
70
+ cleaned_lines = [line.lstrip("# ") for line in lines]
71
+ return "\n".join(cleaned_lines)
72
+ return commented_input
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
 
75