mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: drop array-style problem content (#882)
This commit is contained in:
1 parent
23dfcbeeae
commit
6ae902d3ca
9 files changed
+120
-180
No files matched your search
@@ -168,6 +168,7 @@ export async function run({
|
||||
}
|
||||
if (!pidMap[pdoc.problem_id]) {
|
||||
const files = {};
|
||||
const markdown = [pdoc.description?.[0], pdoc.input?.[0], pdoc.output?.[0], pdoc.hint?.[0]].some((i) => i?.includes('[md]'));
|
||||
let content = buildContent({
|
||||
description: pdoc.description,
|
||||
input: pdoc.input,
|
||||
@@ -175,7 +176,7 @@ export async function run({
|
||||
samples: [[pdoc.sample_input.trim(), pdoc.sample_output.trim()]],
|
||||
hint: pdoc.hint,
|
||||
source: pdoc.source,
|
||||
}, 'html').replace(/<math xm<x>lns=/g, '<math xmlns=');
|
||||
}, 'html').replace(/<math xm<x>lns=/g, '<math xmlns=').replace(/\[\/?md]/g, '');
|
||||
const uploadFiles = content.matchAll(/(?:src|href)="\/upload\/([^"]+\/([^"]+))"/g);
|
||||
for (const file of uploadFiles) {
|
||||
try {
|
||||
@@ -191,6 +192,7 @@ export async function run({
|
||||
1, pdoc.source?.trim().length ? pdoc.source.split(' ').map((i) => i.trim()).filter((i) => i) : [],
|
||||
{ hidden: pdoc.defunct === 'Y' },
|
||||
);
|
||||
if (!markdown) await ProblemModel.edit(domainId, pid, { html: true });
|
||||
pidMap[pdoc.problem_id] = pid;
|
||||
await Promise.all(Object.keys(files).map((filename) => ProblemModel.addAdditionalFile(domainId, pid, filename, files[filename])));
|
||||
if (Object.keys(files).length) report({ message: `move ${Object.keys(files).length} file for problem ${pid}` });
|
||||
|
||||
Reference in new issue
Block a user