import { describe, it, expect } from 'vitest';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { parseMarkdownBlocks } from '../markdownBlocks';
import { privacyAvailable, processingFacts, starterHeadings } from '../privacy';
import type { AppConfig } from '../config/schema';
describe('parseMarkdownBlocks', () => {
it('reads headings, lists and paragraphs', () => {
const blocks = parseMarkdownBlocks(
'# Datenschutz\n\nErster Satz\nzweiter Satz.\n\n### Detail\n- eins\n- **zwei**\n\n1. a\n2. b',
);
expect(blocks).toEqual([
{ type: 'heading', level: 2, html: 'Datenschutz' },
{ type: 'paragraph', html: 'Erster Satz zweiter Satz.' },
{ type: 'heading', level: 3, html: 'Detail' },
{ type: 'list', ordered: false, items: ['eins', 'zwei'] },
{ type: 'list', ordered: true, items: ['a', 'b'] },
]);
});
it('escapes the author text before adding its own tags', () => {
const [p] = parseMarkdownBlocks(' [x](javascript:alert(1))');
const html = p.type === 'paragraph' ? p.html : '';
expect(html).toContain('<script>');
expect(html).not.toContain('