Skip to content

Fix: Allow lists immediately after paragraphs (Issue #254)#260

Merged
schuyler merged 2 commits intomainfrom
claude/issue-254-DsZiR
Jan 8, 2026
Merged

Fix: Allow lists immediately after paragraphs (Issue #254)#260
schuyler merged 2 commits intomainfrom
claude/issue-254-DsZiR

Conversation

@schuyler
Copy link
Copy Markdown
Owner

@schuyler schuyler commented Jan 8, 2026

Summary

  • Adds a preprocessor function MPPreprocessMarkdownForLists that inserts a blank line before list markers when they immediately follow a paragraph
  • Uses regex-based pattern matching with negative lookahead to avoid breaking tight lists
  • Addresses user request for more liberal CommonMark/GFM-style list handling

Technical Details

The fix is a minimal ~20 line preprocessor that:

  1. Matches paragraph lines (non-list-marker lines) followed immediately by list markers (-, *, +, or 1.)
  2. Inserts a blank line between them so Hoedown properly recognizes the list

Known edge cases documented in code:

  • Fenced code blocks containing list-like lines (e.g., - (void)method)
  • Indented code blocks within list context
  • Blockquotes followed by lists

Changes

  • MacDown/Code/Document/MPRenderer.m - Core preprocessor implementation
  • MacDownTests/MPRendererEdgeCaseTests.m - 6 new unit tests
  • Updated golden files to reflect correct list rendering behavior

Test plan

  • All unit tests pass on macOS 14, 15, 15-intel, and 26
  • Verify lists render correctly after paragraphs in the editor
  • Verify tight lists (without blank lines between items) still work
  • Test edge cases mentioned in code comments

Related to #254

claude added 2 commits January 8, 2026 17:03
Add simple regex preprocessing to insert blank lines before list markers
when they immediately follow a non-blank line. This provides CommonMark/GFM
behavior where lists can interrupt paragraphs without requiring a blank line.

Implementation:
- Add MPPreprocessMarkdownForLists() function in MPRenderer.m
- Regex matches list markers (-, *, +, or N.) after non-blank lines
- Inserts blank line to work around Hoedown's strict spacing requirement

Known edge cases (documented in code, intentionally not handled):
- Lists inside fenced code blocks may be incorrectly modified
- Lists inside indented code blocks may be incorrectly modified
- Blockquotes may need special handling

Tests:
- Add 6 unit tests in MPRendererEdgeCaseTests.m for issue #254
- Update regression-issue34.html golden file for correct list rendering

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

github-actions bot commented Jan 8, 2026

Code Coverage Report

Current Coverage: 51.59%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       58.01% (7299/12582) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/DOMNode+Text.m                                                   0.00% (0/94)        
        -[NSString(WordCount) numberOfWords]                                                                                           0.00% (0/11)        
        __36-[NSString(WordCount) numberOfWords]_block_invoke                                                                          0.00% (0/3)         
        -[NSString(WordCount) lengthWithoutNewlines]                                                                                   0.00% (0/11)        
        __44-[NSString(WordCount) lengthWithoutNewlines]_block_invoke                                                                  0.00% (0/3)         
        -[NSString(WordCount) lengthWithoutWhitespacesAndNewlines]                                                                     0.00% (0/11)        
        __58-[NSString(WordCount) lengthWithoutWhitespacesAndNewlines]_block_invoke                                                    0.00% (0/3)         
        MPGetChildrenNodetextCount                                                                                                     0.00% (0/6)         
        MPGetNodeTextCount                                                                                                             0.00% (0/38)        
        -[DOMNode(Text) textCount]                                                                                                     0.00% (0/8)         
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPDocument.m                                                      51.21% (786/1535)   
        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]                                                                                        66.67% (8/12)       
        MPGetPreviewLoadingCompletionHandler                                                                                           100.00% (25/25)     
        __MPGetPreviewLoadingCompletionHandler_block_invoke                                                                            100.00% (22/22)     
        -[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]                                                                                                        0.00% (0/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]                                                                                                             88.89% (8/9)        
        -[MPDocument windowNibName]                                                                                                    100.00% (3/3)       
        -[MPDocument windowControllerDidLoadNib:]                                                                                      100.00% (85/85)     
        __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)       

... (2391 more lines truncated)

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

@schuyler schuyler merged commit 788bad6 into main Jan 8, 2026
9 checks passed
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