MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / detect_indent

Function detect_indent

toon/decoder.py:13–45  ·  view source on GitHub ↗

Detect the indentation size used in a TOON string. Args: toon_string: TOON formatted string Returns: Detected indent size (default 2 if unable to detect)

(toon_string: str)

Source from the content-addressed store, hash-verified

11
12
13def detect_indent(toon_string: str) -> int:
14 """
15 Detect the indentation size used in a TOON string.
16
17 Args:
18 toon_string: TOON formatted string
19
20 Returns:
21 Detected indent size (default 2 if unable to detect)
22 """
23 lines = toon_string.split(NEWLINE)
24
25 for line in lines:
26 if not line or not line[0].isspace():
27 continue
28
29 # Count leading spaces
30 indent = 0
31 for char in line:
32 if char == SPACE:
33 indent += 1
34 elif char == '\t':
35 # Treat tab as 4 spaces
36 return 4
37 else:
38 break
39
40 # If we found indentation, return it
41 if indent > 0:
42 return indent
43
44 # Default to 2 if no indentation found
45 return 2
46
47
48class DecoderOptions:

Callers 1

decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…