How mrspartak/html-ai-ready works
Main Components
• Library API Layer: Represent the public interface (e.g., the exported function htmlToAiReady and preset constants like PRESET_QUALITY) which users import into their projects.
• Core Logic (TypeScript): Show the main logic in the src directory including utility modules (cleanup_html, simplified_markdown, striptag) and type definitions. This layer manages the conversion from HTML to an optimized text representation.
• Testing & Benchmarking: Include a component that represents the tests and benchmarks (tests directory) as these are crucial for validating both output quality and performance.
• Build & Configuration: Indicate support files such as package.json, tsconfig.json, tsup.config.ts, and GitHub workflows (in the .github directory), which are essential for building, testing, and deployment.
Relationships and Interactions
• The API Layer (the entry point from src/index.ts) calls into the Core Logic utilities which perform HTML cleanup and conversion.
• That the Documentation & Examples component is a support artifact which “consumes” or details the implementation of the above components.
• Finally, include a Build & Configuration section that feeds into both the API Layer and the Native Module, highlighting the build tools and scripts used to compile, bundle, and deploy the library.
Architectural Patterns and Design Principles
• Separation of Concerns: Clearly differentiate between the main API, the transformation utilities, and the native (performance) pathway.
• Modularity: Each folder (src, native, tests, docs) represents a module or layer that can be independently maintained and tested.
• Transparent Interoperability: The native module integrates with the JavaScript code through clearly defined bindings; visually indicate that with a connector between the TypeScript layer and the Rust/native layer.
Relevant Technologies, Frameworks, and Tools
• TypeScript (Node.js) is the primary language for the API and utility modules.
• Rust is used for the native module.
• Build Tools: tsup (for bundling), TypeScript configuration (tsconfig.json), and package managers (npm, pnpm, yarn, bun).
• Testing and CI Infrastructure: Vitest (as indicated by vitest.config.ts), and GitHub workflows for automated testing and releases.
• Documentation Tools: Typedoc (typedoc.json) and examples which guide users in leveraging the library’s capabilities.