Skip to content

Fix adjacent shortcut-style links not rendering correctly#275

Merged
schuyler merged 2 commits intomainfrom
claude/hoedown-preprocessor-issues-U7lvQ
Jan 16, 2026
Merged

Fix adjacent shortcut-style links not rendering correctly#275
schuyler merged 2 commits intomainfrom
claude/hoedown-preprocessor-issues-U7lvQ

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

  • Add preprocessor regex to convert shortcut links [text] to explicit form [text][] when followed by whitespace and another [
  • This disambiguates the syntax for Hoedown, which otherwise fails to parse the first link
  • Uses negative lookbehind to avoid breaking reference-style links like [text][ref]

Related Issue

Related to #25

Test Plan

  • Added regression-issue25.md and regression-issue25.html golden files testing adjacent shortcut links
  • Added testRegressionIssue25_AdjacentShortcutLinks unit test
  • All existing tests continue to pass (including testImages which validates the lookbehind works correctly)

Manual Testing

Test the following markdown in the editor preview:

[foo] [bar][baz]

[foo]: https://example.com/foo
[bar]: https://example.com/bar
[baz]: https://example.com/baz

Both [foo] and [bar] should render as clickable links.

Add preprocessor regex to convert shortcut links [text] to explicit form
[text][] when followed by whitespace and another [. This disambiguates
the syntax for Hoedown, which otherwise fails to parse the first link.

The fix requires whitespace between links to avoid incorrectly modifying
explicit reference links like [text][ref].

Related to #25
Add negative lookbehind (?<!\]) to the shortcut link regex to avoid
matching the reference ID part of [text][ref] or ![text][ref] when
it's followed by whitespace and another [.

For example, this prevents incorrectly modifying:
  ![Another reference][img2]

  [img1]: url

where [img2] would have been matched and converted to [img2][]
because it's followed by newlines and then [img1].

Related to #25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 15, 2026

Code Coverage Report

Current Coverage: 52.63%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       58.70% (7585/12922) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/MPMathJaxListener.m                                                0.00% (0/26)        
        -[MPMathJaxListener callbacks]                                                                                                 0.00% (0/5)         
        -[MPMathJaxListener addCallback:forKey:]                                                                                       0.00% (0/3)         
        -[MPMathJaxListener invokeCallbackForKey:]                                                                                     0.00% (0/8)         
        +[MPMathJaxListener isSelectorExcludedFromWebScript:]                                                                          0.00% (0/5)         
        +[MPMathJaxListener isKeyExcludedFromWebScript:]                                                                               0.00% (0/5)         
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPDocument.m                                                      56.29% (1011/1796)  
        MPEditorPreferenceKeyWithValueKey                                                                                              85.71% (6/7)        
        MPEditorKeysToObserve                                                                                                          100.00% (15/15)     
        __MPEditorKeysToObserve_block_invoke                                                                                           100.00% (10/10)     
        MPEditorPreferencesToObserve                                                                                                   100.00% (13/13)     
        __MPEditorPreferencesToObserve_block_invoke                                                                                    100.00% (8/8)       
        MPRectStringForAutosaveName                                                                                                    100.00% (6/6)       
        MPAreNilableStringsEqual                                                                                                       100.00% (3/3)       
        MPGetWebViewBackgroundColor                                                                                                    0.00% (0/9)         
        -[NSURL(Convert) absoluteBaseURLString]                                                                                        0.00% (0/6)         
        -[WebView(Shortcut) enclosingScrollView]                                                                                       100.00% (3/3)       
        -[MPPreferences(Hoedown) extensionFlags]                                                                                       75.00% (21/28)      
        -[MPPreferences(Hoedown) rendererFlags]                                                                                        75.00% (9/12)       
        MPGetPreviewLoadingCompletionHandler                                                                                           100.00% (26/26)     
        __MPGetPreviewLoadingCompletionHandler_block_invoke                                                                            100.00% (23/23)     
        -[MPDocument preferences]                                                                                                      100.00% (3/3)       
        -[MPDocument markdown]                                                                                                         100.00% (3/3)       
        -[MPDocument setMarkdown:]                                                                                                     100.00% (3/3)       
        -[MPDocument html]                                                                                                             0.00% (0/3)         
        -[MPDocument toolbarVisible]                                                                                                   0.00% (0/3)         
        -[MPDocument previewVisible]                                                                                                   100.00% (3/3)       
        -[MPDocument editorVisible]                                                                                                    100.00% (3/3)       
        -[MPDocument needsHtml]                                                                                                        80.00% (4/5)        
        -[MPDocument setTotalWords:]                                                                                                   0.00% (0/7)         
        -[MPDocument setTotalCharacters:]                                                                                              0.00% (0/7)         
        -[MPDocument setTotalCharactersNoSpaces:]                                                                                      0.00% (0/8)         
        -[MPDocument setAutosaveName:]                                                                                                 100.00% (4/4)       
        -[MPDocument init]                                                                                                             90.00% (9/10)       
        -[MPDocument windowNibName]                                                                                                    100.00% (3/3)       
        -[MPDocument windowControllerDidLoadNib:]                                                                                      98.86% (87/88)      
        __41-[MPDocument windowControllerDidLoadNib:]_block_invoke                                                                     100.00% (4/4)       
        -[MPDocument reloadFromLoadedString]                                                                                           100.00% (8/8)       
        -[MPDocument close]                                                                                                            0.00% (0/20)        
        +[MPDocument autosavesInPlace]                                                                                                 100.00% (2/2)       
        +[MPDocument writableTypes]                                                                                                    100.00% (3/3)       
        -[MPDocument isDocumentEdited]                                                                                                 100.00% (5/5)       
        -[MPDocument writeToURL:ofType:error:]                                                                                         0.00% (0/15)        
        -[MPDocument dataOfType:error:]                                                                                                100.00% (3/3)       
        -[MPDocument readFromData:ofType:error:]                                                                                       100.00% (8/8)       
        -[MPDocument prepareSavePanel:]                                                                                                76.92% (30/39)      

... (2471 more lines truncated)

📊 **Full coverage report available in workflow artifacts**

@schuyler schuyler merged commit 3be56f6 into main Jan 16, 2026
10 checks passed
@schuyler schuyler deleted the claude/hoedown-preprocessor-issues-U7lvQ branch January 16, 2026 04:02
schuyler pushed a commit that referenced this pull request Jan 24, 2026
Comprehensive testing plan covering all changes since v3000.0.3:
- Smart quote substitution fix (#289)
- Editor jumping when typing at end of long documents (#288)
- New document window positioning (#286)
- Graphviz/Mermaid button positioning in Compilation Settings (#280)
- Adjacent shortcut-style links rendering (#275)

Includes regression testing checklist for core functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants