MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / transform_body

Function transform_body

scripts/website/bulk_mechanical_fix.py:102–121  ·  view source on GitHub ↗

Apply transforms to a post body, skipping code blocks, tables, indented code, and lines that are entirely a shortcode.

(body, opts, counts)

Source from the content-addressed store, hash-verified

100
101
102def transform_body(body, opts, counts):
103 """Apply transforms to a post body, skipping code blocks, tables, indented
104 code, and lines that are entirely a shortcode."""
105 lines = body.split("\n")
106 in_fence = False
107 out = []
108 for line in lines:
109 if _FENCE_RE.match(line):
110 in_fence = not in_fence
111 out.append(line)
112 continue
113 if in_fence:
114 out.append(line)
115 continue
116 # Indented code (4+ spaces) and table rows are left verbatim.
117 if re.match(r"^ {4,}\S", line) or line.lstrip().startswith("|"):
118 out.append(line)
119 continue
120 out.append(_transform_line(line, opts, counts))
121 return "\n".join(out)
122
123
124def _invariants(body):

Callers 1

process_fileFunction · 0.85

Calls 5

_transform_lineFunction · 0.85
splitMethod · 0.65
appendMethod · 0.65
joinMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected