refactor: finalize MarkdownPreprocessor as clean orchestrator
- 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 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+7
-15
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user