ui: buildContent: add new line between sections

This commit is contained in:
undefined committed 2024-11-05 00:05:21 +08:00
1 parent 332a6aa697
commit d0f9f782b6
1 file changed
+9 -9
+9 -9
View File
@@ -15,15 +15,15 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' =
// required by upgrade 90_91
if (source instanceof Array) {
return type === 'html'
? source.map((node) => [
? source.flatMap((node) => [
node.type !== 'Plain' ? `<h2>${node.sectionTitle}</h2>` : '',
node.type === 'Sample'
? `<pre><code class="language-input${++cnt}">${node.payload[0]}</code></pre>`
+ `<pre><code class="language-output${cnt}">${node.payload[1]}</code></pre>`
: '',
node.text,
].join('\n')).join('\n')
: source.map((node) => [
]).join('\n')
: source.flatMap((node) => [
node.type !== 'Plain' && (node.type !== 'Sample' || !cnt) ? `## ${node.sectionTitle}` : '',
...node.type === 'Sample'
? [
@@ -41,7 +41,7 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' =
'',
node.text,
'',
].join('\n')).join('\n');
]).join('\n');
}
return type === 'html'
? [
@@ -60,9 +60,9 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' =
...source.source ? [`<h2>${_('Source')}</h2>`, source.source] : [],
].join('\n')
: [
...source.description ? [`## ${_('Description')}`, source.description] : [],
...source.input ? [`## ${_('Input Format')}`, source.input] : [],
...source.output ? [`## ${_('Output Format')}`, source.output] : [],
...source.description ? [`## ${_('Description')}`, '', source.description, ''] : [],
...source.input ? [`## ${_('Input Format')}`, '', source.input, ''] : [],
...source.output ? [`## ${_('Output Format')}`, '', source.output, ''] : [],
...(source.samples).map((sample, i) => [
`\`\`\`input${i + 1}`,
sample[0],
@@ -72,8 +72,8 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' =
'```',
].join('\n')),
...source.samplesRaw ? [source.samplesRaw] : [],
...source.hint ? [`## ${_('Hint')}`, source.hint] : [],
...source.source ? [`## ${_('Source')}`, source.source] : [],
...source.hint ? [`## ${_('Hint')}`, '', source.hint, ''] : [],
...source.source ? [`## ${_('Source')}`, '', source.source, ''] : [],
].join('\n');
}