From Combinatorial Mess to Linear Elegance: Architecting a Conversion Engine
5 days ago
- #Swift Programming
- #Intermediate Representation
- #File Format Conversion
- Minimal app supports file format conversion across Markdown, Rich Text, HTML, PDF, plain text, and MNML.
- To manage conversion complexity, an Intermediate Representation (IR) acts as a middleman between formats, simplifying conversions.
- Adding a new format requires building only its specific converter, avoiding direct pairwise conversions.
- IR architecture is analogous to biological systems, like cellular metabolism or the genetic code, which use shared intermediaries.
- IR can lead to architectural lock-in, similar to the 'frozen accident' of the genetic code, making system-wide changes difficult.
- IR's document structure is defined in Swift, with parsers and renderers implemented for each format (e.g., HTML, Markdown).
- Conversion process involves parsing source files into IR and rendering IR into target formats.
- Integration in Minimal app includes import/export features like drag-and-drop, paste, share extension, and keyboard shortcuts.
- Proprietary .mnml file type enables roundtrip export-import without concessions.
- Utilities support file type detection, folder handling, concession reporting, staging for bulk operations, and Rich Text pasteboard.
- Quick Export allows rapid export for uses like copying Markdown into LLMs (e.g., Claude or ChatGPT).