import { readFileSync } from 'node:fs'; import { describe, expect, it } from 'vitest'; import { renderGuide } from './guide.ts'; const GUIDES_URL = 'https://tangled.org/katsuricata.com/Fablewright/blob/main/docs/'; describe('renderGuide', () => { it('turns a heading and a wrapped paragraph into a sentence', () => { const html = renderGuide('# Use Fablewright\n\nThis guide is for the\nwriter.\n'); expect(html).toBe('

Use Fablewright

\n

This guide is for the writer.

'); }); it('keeps heading levels', () => { const html = renderGuide('## Start\n\n### When a save fails\n'); expect(html).toContain('

Start

'); expect(html).toContain('

When a save fails

'); }); it('renders bullets, numbered steps, and a wrapped item', () => { const html = renderGuide( '1. Open the address.\n2. Create an account.\n\n- **Details** changes the title\n and the subtitle.\n- **Export** downloads the project.\n' ); expect(html).toContain('
  1. Open the address.
  2. Create an account.
'); expect(html).toContain( '' ); }); it('formats bold, italic and inline code', () => { const html = renderGuide('Press `Ctrl` + `S` for **bold** and *italic*.\n'); expect(html).toBe( '

Press Ctrl + S for bold and italic.

' ); }); it('formats underscore italics, as Prettier writes them', () => { const html = renderGuide('Open _Your account_ from the header.\n'); expect(html).toBe('

Open Your account from the header.

'); }); it('leaves an identifier and the text inside a code span alone', () => { const html = renderGuide('Set a_b_c and `x_y_z` and `2*3*4`.\n'); expect(html).toBe('

Set a_b_c and x_y_z and 2*3*4.

'); }); it('treats the document as text, never as markup', () => { const html = renderGuide(' and **bold**\n'); expect(html).not.toContain('