From 57555fa859f80523eb75d7fff4791638582f50ec Mon Sep 17 00:00:00 2001 From: Jarvis Date: Tue, 9 Sep 2025 22:45:46 +0200 Subject: [PATCH] refactor: finalize MarkdownPreprocessor as clean orchestrator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove unused regex patterns (WIKILINK_PATTERN, TAG_PATTERN) - Fix step numbering in processing pipeline (1-6 sequential) - Remove extra whitespace and improve code organization - Reduce from 213 to 204 lines (target ~200 lines achieved) - Clean orchestration focused on delegation to processors - Build verification passes without errors MarkdownPreprocessor now serves as pure orchestrator: - Configuration management and processor coordination - 6-step processing pipeline with clear delegation - No trapped implementation details in main class - Clean error handling and result compilation Phase 2 complete: 1792 → 204 lines (88% reduction) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- plan.md | 4 ++-- src/converters/MarkdownPreprocessor.ts | 18 +++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/plan.md b/plan.md index 8903fb5..10c388e 100644 --- a/plan.md +++ b/plan.md @@ -154,8 +154,8 @@ The main.ts file is the plugin entry point and most critical to get right. **STOP** → Verify build → Test metadata extraction works -### Step 2.6: Update MarkdownPreprocessor.ts - IN PROGRESS -**Final size:** ~200 lines +### Step 2.6: Update MarkdownPreprocessor.ts - DONE +**Final size:** 204 lines (target ~200 lines) **Keep:** - Main `preprocess()` method - Orchestration logic diff --git a/src/converters/MarkdownPreprocessor.ts b/src/converters/MarkdownPreprocessor.ts index 21ded49..925e05e 100644 --- a/src/converters/MarkdownPreprocessor.ts +++ b/src/converters/MarkdownPreprocessor.ts @@ -80,10 +80,6 @@ export class MarkdownPreprocessor { private embedProcessor: EmbedProcessor; private calloutProcessor: CalloutProcessor; - // Regex patterns for Obsidian syntax - private readonly WIKILINK_PATTERN = /\[\[([^\|\]]+)(?:\|([^\]]+))?\]\]/g; - private readonly TAG_PATTERN = /#(?:[^\s#]+)/g; - constructor(config: MarkdownPreprocessorConfig) { this.vaultPath = config.vaultPath; this.options = config.options; @@ -130,20 +126,19 @@ export class MarkdownPreprocessor { // Step 1: Extract and process frontmatter first (always process for metadata extraction) result.content = this.frontmatterProcessor.processFrontmatter(result.content, result); - - // Step 3: Convert email blocks to Typst format + // Step 2: Convert email blocks to Typst format result.content = this.calloutProcessor.processEmailBlocks(result.content, result); - // Step 4: Filter out unnecessary links (Open: links and Mail.app links) + // Step 3: Filter out unnecessary links (Open: links and Mail.app links) result.content = this.calloutProcessor.filterUnnecessaryLinks(result.content, result); - // Step 5: Convert embeds FIRST (before wikilinks to avoid .md extension being added) + // Step 4: Convert embeds FIRST (before wikilinks to avoid .md extension being added) result.content = this.embedProcessor.processEmbeds(result.content, result); - // Step 6: Convert wikilinks (after embeds are processed) + // Step 5: Convert wikilinks (after embeds are processed) result.content = this.wikilinkProcessor.processWikilinks(result.content, result); - // Step 7: Convert callouts + // Step 6: Convert callouts result.content = this.calloutProcessor.processCallouts(result.content, result); // Extract title from content if not available from frontmatter @@ -158,9 +153,6 @@ export class MarkdownPreprocessor { return result; } - - - /** * Update configuration */