feat: release 1.1.0 with responsive task control
This commit is contained in:
1 parent
057f0c3050
commit
bfcd828fa8
37 files changed
+1601
-151
No files matched your search
@@ -67,4 +67,12 @@ describe('markdown-parser.util verification & check lines', () => {
|
||||
expect(html).toContain('<span class="verify-badge">verify</span>');
|
||||
expect(html).toContain('status is ok');
|
||||
});
|
||||
|
||||
it('renders Chinese report tables and preserves separate lines safely', () => {
|
||||
const html = renderMarkdownToHtml('## 结论\n第一行\n第二行\n\n| 分类 | 结果 |\n| --- | --- |\n| 网络 | **通过** |');
|
||||
expect(html).toContain('<h2>结论</h2>');
|
||||
expect(html).toContain('<div>第一行</div>\n<div>第二行</div>');
|
||||
expect(html).toContain('<th>分类</th>');
|
||||
expect(html).toContain('<td><strong>通过</strong></td>');
|
||||
});
|
||||
});
|
||||
@@ -272,7 +272,7 @@ export function renderMarkdownToHtml(text: string): string {
|
||||
if (inCodeBlock) {
|
||||
// End code block
|
||||
const codeContent = codeBlockLines.join('\n');
|
||||
result.push(`<pre class="code-block"><code class="lang-${codeBlockLang}">${codeContent}</code></pre>`);
|
||||
result.push(`<pre class="code-block"><code class="lang-${codeBlockLang.replace(/[^a-zA-Z0-9_-]/g, '')}">${codeContent}</code></pre>`);
|
||||
inCodeBlock = false;
|
||||
codeBlockLines = [];
|
||||
codeBlockLang = '';
|
||||
@@ -290,6 +290,26 @@ export function renderMarkdownToHtml(text: string): string {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Markdown result tables need real cells to remain readable in reports.
|
||||
if (trimmed.includes('|') && i + 1 < rawLines.length
|
||||
&& /^\s*\|?\s*:?-{3,}:?(?:\s*\|\s*:?-{3,}:?)*\s*\|?\s*$/.test(rawLines[i + 1])) {
|
||||
closeList();
|
||||
const cells = (line: string) => line.trim().replace(/^\|/, '').replace(/\|$/, '').split('|');
|
||||
const headings = cells(rawLine);
|
||||
result.push('<div class="md-table-scroll"><table><thead><tr>'
|
||||
+ headings.map(cell => `<th>${formatInlineMarkdown(cell.trim())}</th>`).join('')
|
||||
+ '</tr></thead><tbody>');
|
||||
i += 2;
|
||||
while (i < rawLines.length && rawLines[i].trim() && rawLines[i].includes('|')) {
|
||||
const row = cells(rawLines[i]);
|
||||
result.push('<tr>' + headings.map((_, index) => `<td>${formatInlineMarkdown((row[index] || '').trim())}</td>`).join('') + '</tr>');
|
||||
i++;
|
||||
}
|
||||
result.push('</tbody></table></div>');
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. Headings: # to ######
|
||||
const headingMatch = trimmed.match(/^(#{1,6})\s+(.*)$/);
|
||||
if (headingMatch) {
|
||||
@@ -375,7 +395,7 @@ export function renderMarkdownToHtml(text: string): string {
|
||||
|
||||
if (inCodeBlock) {
|
||||
const codeContent = codeBlockLines.join('\n');
|
||||
result.push(`<pre class="code-block"><code class="lang-${codeBlockLang}">${codeContent}</code></pre>`);
|
||||
result.push(`<pre class="code-block"><code class="lang-${codeBlockLang.replace(/[^a-zA-Z0-9_-]/g, '')}">${codeContent}</code></pre>`);
|
||||
}
|
||||
|
||||
closeList();
|
||||
|
||||
Reference in new issue
Block a user