Skip to content

Disable text substitutions by default for all users#268

Merged
schuyler merged 1 commit intomainfrom
claude/configurable-toggle-feature-XnRa4
Jan 12, 2026
Merged

Disable text substitutions by default for all users#268
schuyler merged 1 commit intomainfrom
claude/configurable-toggle-feature-XnRa4

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

This PR adds a one-time migration fix that resets all text substitution settings to OFF for all users. This addresses issue #263 where smart dashes (and other text substitutions) break Markdown syntax.

Changes:

  • Added code to loadDefaultUserDefaults in MPPreferences.m that:
    • Checks for the MPDidApplySubstitutionDefaultsFix flag
    • If not set, resets all 8 text substitution settings to OFF
    • Sets the flag to prevent future overrides

Settings disabled:

  • Smart Dashes (breaks --- horizontal rules and table syntax)
  • Smart Quotes (breaks inline code and YAML)
  • Text Replacement, Spelling Correction, Smart Insert/Delete
  • Data Detectors, Spell Checking, Grammar Checking

Behavior:

  • New users: All substitutions OFF by default
  • Migrated users with broken defaults: Get fixed
  • Users who explicitly enable after fix: Their choice preserved

Related Issue

Related to #263

Manual Testing Plan

Scenario 1: Fresh Installation

  1. Remove all MacDown preferences: defaults delete app.macdown.macdown3000
  2. Launch MacDown 3000
  3. Check Edit > Substitutions - all options should be unchecked

Scenario 2: Migrated User with Bad Defaults

  1. Set bad defaults: defaults write app.macdown.macdown3000 editorAutomaticDashSubstitutionEnabled -bool YES
  2. Remove fix flag: defaults delete app.macdown.macdown3000 MPDidApplySubstitutionDefaultsFix
  3. Launch MacDown 3000
  4. Check Edit > Substitutions - all options should now be unchecked

Scenario 3: User Choices Preserved

  1. Complete Scenario 1
  2. Enable Smart Quotes via Edit > Substitutions
  3. Quit and relaunch MacDown
  4. Smart Quotes should remain enabled

Scenario 4: Functional Verification

  1. Type --- - should remain as dashes (not convert to em-dash)
  2. Type | Col1 | Col2 | then |---|---| - table syntax should work
  3. Type "text" - should remain straight quotes

Review Notes

  • Code review passed (follows existing project conventions)
  • No documentation updates needed
  • CI tests pass on all macOS versions (14, 15, 26, 15-intel)

Add a one-time migration fix that resets all text substitution settings
(smart dashes, smart quotes, spelling correction, etc.) to OFF. This
ensures that both new users and users who migrated from old MacDown get
the correct defaults for a Markdown editor.

Text substitutions break Markdown syntax:
- Smart dashes convert --- to em-dash (breaks horizontal rules and tables)
- Smart quotes convert straight quotes to curly (breaks code blocks)
- Spelling correction can mangle technical terms

The fix uses a flag (MPDidApplySubstitutionDefaultsFix) to ensure it only
runs once, so subsequent explicit user choices via Edit > Substitutions
are preserved.

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

github-actions bot commented Jan 12, 2026

Code Coverage Report

Current Coverage: 51.67%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       57.95% (7339/12665) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/NSColor+HTML.m                                                   94.05% (332/353)    
        +[NSColor(HTML) colorWithHexString:]                                                                                           94.12% (16/17)      
        +[NSColor(HTML) colorWithHTMLName:]                                                                                            89.13% (164/184)    
        __35+[NSColor(HTML) colorWithHTMLName:]_block_invoke                                                                           100.00% (152/152)   
    /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/Dependency/peg-markdown-highlight/HGMarkdownHighlightingStyle.m                         87.69% (57/65)      
        +[HGMarkdownHighlightingStyle colorFromARGBColor:]                                                                             100.00% (6/6)       
        -[HGMarkdownHighlightingStyle initWithType:attributesToAdd:toRemove:fontTraitsToAdd:]                                          88.89% (8/9)        
        -[HGMarkdownHighlightingStyle initWithStyleAttributes:baseFont:]                                                               86.00% (43/50)      
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/hoedown_html_patch.c                                             88.37% (114/129)    
        hoedown_patch_render_blockcode                                                                                                 89.09% (49/55)      
        hoedown_patch_render_listitem                                                                                                  100.00% (46/46)     
        hoedown_patch_render_toc_header                                                                                                67.86% (19/28)      
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Application/MPMainController.m                                             42.91% (106/247)    
        MPOpenBundledFile                                                                                                              96.67% (29/30)      
        __MPOpenBundledFile_block_invoke                                                                                               85.71% (6/7)        
        treat                                                                                                                          20.00% (6/30)       
        __treat_block_invoke                                                                                                           0.00% (0/3)         
        -[MPMainController applicationDidFinishLaunching:]                                                                             100.00% (6/6)       
        -[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]                                                                    0.00% (0/45)        
        __59-[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]_block_invoke                                                   0.00% (0/7)         
        -[MPMainController valueForKey:fromQueryItems:]                                                                                0.00% (0/5)         
        -[MPMainController preferences]                                                                                                100.00% (3/3)       
        -[MPMainController preferencesWindowController]                                                                                0.00% (0/18)        
        -[MPMainController showPreferencesWindow:]                                                                                     0.00% (0/2)         
        -[MPMainController showHelp:]                                                                                                  100.00% (3/3)       
        -[MPMainController showContributing:]                                                                                          100.00% (3/3)       
        -[MPMainController init]                                                                                                       90.91% (10/11)      
        -[MPMainController applicationShouldOpenUntitledFile:]                                                                         80.00% (4/5)        
        -[MPMainController applicationDidBecomeActive:]                                                                                100.00% (5/5)       
        -[MPMainController copyFiles]                                                                                                  63.33% (19/30)      
        -[MPMainController openPendingFiles]                                                                                           29.41% (5/17)       
        -[MPMainController openPendingPipedContent]                                                                                    28.57% (4/14)       
        -[MPMainController showFirstLaunchTips]                                                                                        100.00% (3/3)       
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/MPUtilities.m                                                      65.62% (105/160)    
        MPDataRootDirectory                                                                                                            100.00% (14/14)     
        MPDataDirectory                                                                                                                100.00% (5/5)       
        MPPathToDataFile                                                                                                               100.00% (4/4)       
        MPListEntriesForDirectory                                                                                                      0.00% (0/19)        
        MPFileNameHasExtensionProcessor                                                                                                0.00% (0/11)        
        __MPFileNameHasExtensionProcessor_block_invoke                                                                                 0.00% (0/8)         

... (2401 more lines truncated)

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

@schuyler schuyler merged commit d1cd8c2 into main Jan 12, 2026
9 checks passed
@schuyler schuyler deleted the claude/configurable-toggle-feature-XnRa4 branch January 12, 2026 20:59
schuyler pushed a commit that referenced this pull request Jan 13, 2026
This commit implements GitHub issue #269, adding:

1. **Enable checkbox/task list by default** - Added one-time migration in
   MPPreferences.m that enables htmlTaskList for all users who haven't
   explicitly set a preference (following the pattern from #268).

2. **Interactive checkboxes** - Clicking a checkbox in the preview now
   toggles its state in the source document:
   - Modified hoedown_html_patch.c to add data-checkbox-index attribute
   - Updated tasklist.js with click handlers using custom URL scheme
   - Added handleCheckboxToggle: and toggleCheckboxAtIndex:inMarkdown:
     methods in MPDocument.m to handle the toggle logic

3. **Comprehensive tests** - Added TDD tests covering:
   - Migration behavior (MPPreferencesTests.m)
   - Checkbox index rendering (MPMarkdownRenderingTests.m)
   - Toggle logic and edge cases (MPCheckboxToggleTests.m)

4. **Updated golden files** - Updated task-lists.html and mixed-complex.html
   to include the new data-checkbox-index attributes.

Related to #269
schuyler pushed a commit that referenced this pull request Jan 25, 2026
Added comprehensive test cases for PR #268 which addresses issue #263:
- Fresh installation verification (substitutions OFF by default)
- Horizontal rule and table syntax preservation
- Migration fix for users with bad defaults
- User choice preservation after enabling substitutions
- All substitution types verified (dashes, quotes, text replacement, spelling)
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