From 86689e8d4c548339353d3812acbbe9ef48e671fc Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 2 Sep 2020 22:54:15 +0800 Subject: [PATCH] fix: import --- packages/fps-importer/handler.ts | 45 ++++++++++--------- packages/fps-importer/package.json | 2 +- .../template/problem_import_fps.html | 2 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/packages/fps-importer/handler.ts b/packages/fps-importer/handler.ts index e948560e2..f4f0c57d3 100644 --- a/packages/fps-importer/handler.ts +++ b/packages/fps-importer/handler.ts @@ -24,40 +24,45 @@ class FpsProblemImportHandler extends Handler { const content = []; if (p.description) { content.push( - this.translate('problem.import.problem_description'), - p.description.join('\n'), + `

${this.translate('Description')}

`, + ...p.description, ); } if (p.input) { content.push( - this.translate('problem.import.input_format'), - p.input.join('\n'), + `

${this.translate('Input Format')}

`, + ...p.input, ); } if (p.output) { content.push( - this.translate('problem.import.output_format'), - p.output.join('\n'), + `

${this.translate('Output Format')}

`, + ...p.output, ); } if (p.sample_input) { - content.push( - this.translate('problem.import.sample_input'), - // eslint-disable-next-line prefer-template - p.sample_input.map((i: string) => ('```\n' + i + '\n```')).join('\n'), - ); - } - if (p.sample_output) { - content.push( - this.translate('problem.import.sample_output'), - // eslint-disable-next-line prefer-template - p.sample_output.map((i: string) => ('```\n' + i + '\n```')).join('\n'), - ); + if (p.sample_input.length === 1) { + content.push( + `

${this.translate('Sample Input')}

`, + `
${p.sample_input[0]}
`, + `

${this.translate('Sample Output')}

`, + `
${p.sample_output[0]}
`, + ); + } else { + for (let i = 0; i < p.sample_input.length; i++) { + content.push( + `

${this.translate('Sample Input')}${i + 1}

`, + `
${p.sample_input[i]}
`, + `

${this.translate('Sample Output')}${i + 1}

`, + `
${p.sample_output[i]}
`, + ); + } + } } if (p.hint) { content.push( - this.translate('problem.import.hint'), - p.hint.join('\n'), + `

${this.translate('Hint')}

`, + ...p.hint, ); } const config: LocalProblemConfig = { diff --git a/packages/fps-importer/package.json b/packages/fps-importer/package.json index 9aa0753e7..711357e98 100644 --- a/packages/fps-importer/package.json +++ b/packages/fps-importer/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/fps-importer", - "version": "1.0.3", + "version": "1.0.4", "description": "Import FPS problems", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/fps-importer/template/problem_import_fps.html b/packages/fps-importer/template/problem_import_fps.html index 537b3d1dc..640c1968e 100644 --- a/packages/fps-importer/template/problem_import_fps.html +++ b/packages/fps-importer/template/problem_import_fps.html @@ -8,7 +8,7 @@