From f1778443366ed702def3fcde0556feee5fd82103 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 17 Nov 2024 23:28:49 +0800 Subject: [PATCH] core: fix #908 --- packages/hydrooj/src/lib/content.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hydrooj/src/lib/content.ts b/packages/hydrooj/src/lib/content.ts index 3337be70d..b777c4177 100644 --- a/packages/hydrooj/src/lib/content.ts +++ b/packages/hydrooj/src/lib/content.ts @@ -48,7 +48,7 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' = ...source.description ? [`

${_('Description')}

`, source.description] : [], ...source.input ? [`

${_('Input Format')}

`, source.input] : [], ...source.output ? [`

${_('Output Format')}

`, source.output] : [], - ...(source.samples).map((sample, i) => [ + ...(source.samples || []).map((sample, i) => [ `
`,
                 sample[0],
                 `
`,
@@ -63,14 +63,14 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' =
             ...source.description ? [`## ${_('Description')}`, '', source.description, ''] : [],
             ...source.input ? [`## ${_('Input Format')}`, '', source.input, ''] : [],
             ...source.output ? [`## ${_('Output Format')}`, '', source.output, ''] : [],
-            ...(source.samples).map((sample, i) => [
+            ...(source.samples || []).flatMap((sample, i) => [
                 `\`\`\`input${i + 1}`,
                 sample[0],
                 '```',
                 `\`\`\`output${i + 1}`,
                 sample[1],
                 '```',
-            ].join('\n')),
+            ]),
             ...source.samplesRaw ? [source.samplesRaw] : [],
             ...source.hint ? [`## ${_('Hint')}`, '', source.hint, ''] : [],
             ...source.source ? [`## ${_('Source')}`, '', source.source, ''] : [],