AGENTS.md
Guidance for coding agents working on AlexandrAI Tools HTML To Markdown in the alexandrai-tools project.
Project overview
This guide covers src/tools/html-to-markdown. stripScripts removes script and style blocks with case-insensitive regular expressions while leaving ordinary HTML intact. Body.astro imports TurndownService, cleans the pasted HTML with stripScripts, converts the cleaned HTML to Markdown, and displays the result without uploading input.
Primary source files
- src/tools/html-to-markdown/index.ts defines meta, ConvertResult, and stripScripts.
- src/tools/html-to-markdown/index.test.ts covers script removal, style removal, regular HTML preservation, and multiple script/style blocks.
- src/tools/html-to-markdown/Body.astro owns textarea input, Turndown conversion, output rendering, and copy behavior.
- src/tools/html-to-markdown/i18n.ts owns localized labels.
- src/lib/tools.ts registers the tool metadata.
Setup commands
npm install npm test npm run typecheck npm run build npm run dev
Change rules
- Strip script blocks before conversion.
- Strip style blocks before conversion.
- Use case-insensitive matching for stripped tags.
- Leave regular HTML content unchanged before Turndown conversion.
- Keep conversion browser-local.
- Do not treat stripScripts as a complete sanitizer.
- Update tests if additional dangerous or noisy tags are stripped.
Testing
Test script tags, style tags, mixed casing, multiple blocks, ordinary HTML, Turndown output for headings and links, empty input, copy behavior, and security copy.
PR checklist
- npm test passes for html-to-markdown.
- Pure helper behavior and browser UI behavior are aligned.
- Generated CSS, Markdown, JSON, or image output remains browser-local.
- Invalid input, copy behavior, and privacy expectations are covered.