MCPcopy Create free account
hub / github.com/dot-agent/nextpy / format_string

Function format_string

nextpy/utils/format.py:179–196  ·  view source on GitHub ↗

Format the given string as a JS string literal.. Args: string: The string to format. Returns: The formatted string.

(string: str)

Source from the content-addressed store, hash-verified

177
178
179def format_string(string: str) -> str:
180 """Format the given string as a JS string literal..
181
182 Args:
183 string: The string to format.
184
185 Returns:
186 The formatted string.
187 """
188 # Escape backticks.
189 string = string.replace(r"\`", "`")
190 string = string.replace("`", r"\`")
191
192 # Wrap the string so it looks like {`string`}.
193 string = wrap(string, "`")
194 string = wrap(string, "{")
195
196 return string
197
198
199def format_var(var: Var) -> str:

Callers 2

format_varFunction · 0.85
format_propFunction · 0.85

Calls 1

wrapFunction · 0.85

Tested by

no test coverage detected