How mopires/pretty-markup works
Main Components
• Input / Preprocessor CLI: Represent where users provide their Pretty Markup (.pm) files. This entry point is triggered either via the command line (using “pm” or “npx pm”) or through programmatic imports.
• File Manager Module: (src/modules/FileManager.ts) This component deals with reading files from the ./src directory where the .pm files live.
• Tokenizer Module: (src/modules/Tokenizer.ts) The first stage in “compiling” the input where the raw text is broken down into tokens.
• Lexical Analyzer Module: (src/modules/LexicalAnalizer.ts) Likely performs additional processing on tokens – such as validating or refining token sequences.
• Parser Module: (src/modules/Parser.ts) Converts the token stream into an Abstract Syntax Tree (AST) or other structured intermediate representation that can later be rendered as HTML.
• Stream Submodule: (src/modules/stream/index.ts) This helper module is probably used by the processing components for handling data streams (e.g., sequential reading or buffered input).
• Configuration: (src/config directory and files like build.ts, dev.ts, env.json) These contain different environment and build settings influencing how the compiler runs under various conditions.
• Interface Definitions: (src/interface folder) Serve to strictly define the types and expected structure for build settings, elements, and files that flow between modules.
• Main Entry Point: (src/Main.ts and src/index.ts) These files act as the application’s bootstrap where modules are assembled to perform the compilation from Pretty Markup to HTML.
Relationships and Data Flow
• Next, represent the File Manager reading this content from a file system (as indicated by the instructions in the README).
• From the Tokenizer, show a subsequent flow into the Lexical Analyzer, indicating additional processing/refinement.
• Finally, illustrate that the output of the Parser is used to generate standard HTML code. This generated HTML might be displayed on a console or written to an output file.
• Also, highlight the use of TypeScript interfaces (displayed as a layer that underpins the modules) showing contract-based interactions between components.
Architectural Patterns and Design Principles
• Modularity: Each core functionality (e.g., file management, tokenization, parsing) is encapsulated in distinct modules.
• Pipeline / Staged Compilation: The sequential processing steps (from raw input to tokens to an AST and then HTML output) reflect classic compiler pipelines.
• Separation of Configuration: The environment-specific and build configurations are segregated from the main code logic.
• Type Safety: The use of explicit interfaces enforces contracts between different layers and modules.