MCPcopy Create free account
hub / github.com/fa0311/TwitterInternalAPIDocument / parentheses_placeholder

Function parentheses_placeholder

lib/js_parser/js_parser.py:172–194  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

170
171
172def parentheses_placeholder(text: str):
173 length = len(text)
174 key = 0
175 placeholder = 0
176 depth = 0
177 output = parentheses_placeholder_data()
178 output.list.append("")
179 while length > key:
180 char = text[key]
181 key += 1
182 if char == "(":
183 depth += 1
184 if depth == 1:
185 output.text += f"{{{placeholder}}}"
186 output.list.append("")
187 placeholder += 1
188 elif char == ")":
189 depth -= 1
190 elif depth == 0:
191 output.text += char
192 else:
193 output.list[-1] += char
194 return output
195
196
197class parentheses_placeholder_data:

Callers 1

json_parserFunction · 0.85

Calls 1

Tested by

no test coverage detected