Skip to content

Commit 1500cec

Browse files
committed
Fixing tqdm
1 parent 192600b commit 1500cec

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

script.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,29 +245,44 @@ async function runCodeInline() {
245245

246246
// Process each part after splitting by \r
247247
for (let j = 0; j < parts.length; j++) {
248-
const part = parts[j].trim();
248+
const part = parts[j];
249249
const isLastPart = j === parts.length - 1;
250250

251-
if (!part) continue;
251+
if (!part.trim()) continue;
252252

253-
// Check if this is a tqdm line (contains "it/s]")
254-
if (part.includes('it/s]')) {
255-
// Only include if it's the final 100% line and it's the last part
256-
if (part.startsWith('100%') && isLastPart) {
257-
cleanLines.push(part);
253+
// Check if this contains a tqdm line (contains "it/s]")
254+
const tqdmMatch = part.match(/^(.*?it\/s\])(.*?)$/);
255+
256+
if (tqdmMatch) {
257+
const tqdmPart = tqdmMatch[1].trim();
258+
const afterTqdm = tqdmMatch[2].trim();
259+
260+
// Only include the 100% tqdm line if it's the last part
261+
if (tqdmPart.startsWith('100%') && isLastPart) {
262+
cleanLines.push(tqdmPart);
258263
lastWasTqdm = true;
264+
265+
// If there's content after the tqdm line, add it on a new line
266+
if (afterTqdm) {
267+
cleanLines.push('');
268+
cleanLines.push(afterTqdm);
269+
lastWasTqdm = false;
270+
}
259271
} else if (!isLastPart) {
260272
// Intermediate tqdm update, skip but mark as tqdm
261273
lastWasTqdm = true;
262274
}
263275
} else {
264276
// Not a tqdm line, it's regular content
265-
// If previous was tqdm 100%, add empty line for separation
266-
if (lastWasTqdm) {
267-
cleanLines.push('');
268-
lastWasTqdm = false;
277+
const trimmed = part.trim();
278+
if (trimmed) {
279+
// If previous was tqdm 100%, add empty line for separation
280+
if (lastWasTqdm) {
281+
cleanLines.push('');
282+
lastWasTqdm = false;
283+
}
284+
cleanLines.push(trimmed);
269285
}
270-
cleanLines.push(part);
271286
}
272287
}
273288
} else {

0 commit comments

Comments
 (0)