fix: implement link style conversion in convert command #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the convert command's link style conversion functionality by implementing the previously empty
convertLinkStyle
method. This resolves the issue wheremarkmv convert --link-style combined
would report "No changes needed" even when there were standard markdown links that should be converted.Problem
The
convertLinkStyle
method inLinkConverter
was just a placeholder that always returnedfalse
, meaning no link style conversions were ever performed. This caused the convert command to incorrectly report "No changes needed" for all link style conversion requests.Solution
Key Changes
Implemented full
convertLinkStyle
method with support for all link formats:markdown
: Standard[text](url)
formatcombined
: Combined[@url](url)
formatclaude
: Claude import@url
formatwikilink
: Obsidian[[url]]
formatAdded link style detection to determine current format and avoid double-conversion
Added proper AST manipulation for each conversion type with appropriate node transformations
Added conversion validation to only convert internal links and prevent unnecessary changes
Implementation Details
detectCurrentLinkStyle()
: Identifies current link format based on text content and node structureconvertToCombined()
: Converts standard markdown to combined format[@url](url)
convertToClaude()
: Converts to Claude import format@url
convertToWikilink()
: Converts to Obsidian wikilink format[[url]]
convertToMarkdown()
: Converts back to standard markdown formatTesting
✅ Before Fix:
$ markmv convert test.md --link-style combined --verbose No changes needed in test.md Files modified: 0
✅ After Fix:
$ markmv convert test.md --link-style combined --verbose Converted 4 links in test.md Files modified: 1
✅ Conversion Example:
✅ No Double-Conversion:
Running the same command twice correctly reports "No changes needed" on the second run.
Breaking Changes
None - this fixes existing functionality without changing the API.
Test Plan
Related Issues
Resolves #32: markmv convert --link-style combined reports "No changes needed" for standard markdown links