Skip to content

Commit

Permalink
Fix Mendo problem parser for multiple tbodies
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Mar 17, 2024
1 parent 4bcd903 commit 0d5bba7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/parsers/problem/MendoProblemParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ export class MendoProblemParser extends Parser {
task.setMemoryLimit(parseInt(results[5]));
});

if (elem.querySelector('.taskContentView tbody')) {
elem.querySelector('.taskContentView tbody').childNodes.forEach(x => {
const parsed = /^(?:input|влез)\n(.*)(?:output|излез)\n(.*)$/s.exec(x.textContent);
const sampleCasePattern = /^(?:input|влез)\n(.*)(?:output|излез)\n(.*)$/s;
for (const tbody of elem.querySelectorAll('.taskContentView tbody')) {
if ([...tbody.childNodes].some(child => !sampleCasePattern.test(child.textContent))) {
continue;
}

for (const child of tbody.childNodes) {
const parsed = sampleCasePattern.exec(child.textContent);
task.addTest(parsed[1] + '\n', parsed[2] + '\n');
});
} else {
// As of now there isn't a better discovered way of checking if it's interactive :rofl:
task.setInteractive(true);
}
}

// As of now there isn't a better discovered way of checking if it's interactive :rofl:
task.setInteractive(task.tests.length === 0);

return task.build();
}
}

0 comments on commit 0d5bba7

Please sign in to comment.