MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / fix

Function fix

script/check-md-table-padding.ts:163–191  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

161}
162
163function fix(file: string) {
164 const src = readFileSync(path.join(ROOT, file), 'utf8');
165 const lines = src.split('\n');
166 let changed = false;
167 let fence: string | null = null;
168 for (let i = 0; i < lines.length; i++) {
169 const line = lines[i];
170 const trim = line.trim();
171 const fenceMatch = trim.match(/^(`{3,}|~{3,})/);
172 if (fenceMatch) {
173 const marker = fenceMatch[1][0];
174 if (fence === null) fence = marker;
175 else if (marker === fence) fence = null;
176 continue;
177 }
178 if (fence !== null) continue;
179 if (!line.trimStart().startsWith('|')) continue;
180 if (!line.trimEnd().endsWith('|')) continue;
181
182 const sep = isSep(line);
183 const next = rewriteRow(line, sep);
184 if (next !== line) {
185 lines[i] = next;
186 changed = true;
187 }
188 }
189 if (changed) writeFileSync(path.join(ROOT, file), lines.join('\n'));
190 return changed;
191}
192
193const argv = process.argv.slice(2);
194const fixFlag = argv.includes('--fix');

Callers 1

Calls 3

isSepFunction · 0.85
rewriteRowFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected