- 
                Notifications
    You must be signed in to change notification settings 
- Fork 32
Fix right-side navigation order when snippets are included #1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    - Modified GetAnchors method to preserve line number from include directive - Included snippet headings now appear at the correct position in TOC - Changed from assigning line 0 to using actual include block line number - This ensures right-side navigation respects document order Co-authored-by: reakaleek <[email protected]>
- Updated test to properly verify heading order in PageTableOfContent - Verified fix works correctly with manual testing - Snippet headings now appear in correct document order Co-authored-by: reakaleek <[email protected]>
      
          
Copilot
AI
        changed the title
[WIP] Right-side navigation not respecting heading order when snippets are used
Fix right-side navigation order when snippets are included
      Sep 18, 2025 
    
      
        Copilot stopped work on behalf of 
  reakaleek  due to an error
    September 18, 2025 10:32         
    
              
                    reakaleek
  
              
              requested changes
              
                  
                    Sep 18, 2025 
                  
              
              
            
            
- Added test for include before headings (IncludeBeforeHeadingsOrderTests) - Added test for include in middle of headings (IncludeInMiddleOfHeadingsOrderTests) - Tests verify correct heading order for all include positions - All 598 unit tests pass successfully Co-authored-by: reakaleek <[email protected]>
    
          Copilot finished work on behalf of 
  reakaleek 
    September 18, 2025 10:41     
    
              
                    reakaleek
  
              
              requested changes
              
                  
                    Sep 18, 2025 
                  
              
              
            
            
- Added IncludeWithStepperOrderTests: Tests stepper components combined with include directives - Added StepperBeforeIncludeOrderTests: Tests stepper components before include directives - Tests verify correct TOC ordering for stepper steps from both main document and included snippets - All 604 unit tests pass successfully (6 new tests added) Co-authored-by: reakaleek <[email protected]>
    
        Copilot stopped work on behalf of 
  reakaleek  due to an error
    September 18, 2025 11:00         
    
              
                    reakaleek
  
              
              requested changes
              
                  
                    Sep 18, 2025 
                  
              
              
            
            
- Changed all realistic headings to numbered words (One, Two, Three, etc.) - Updated all expected TOC orders to follow sequential numbering - Makes it easy to verify correct heading order in test output - All 604 unit tests pass successfully Co-authored-by: reakaleek <[email protected]>
              
                    reakaleek
  
              
              approved these changes
              
                  
                    Sep 18, 2025 
                  
              
              
            
            
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
              
                    cotti
  
              
              approved these changes
              
                  
                    Sep 19, 2025 
                  
              
              
            
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  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.
  
    
  
    
Fixed heading order issue when snippets are included
Problem
When using
:::{include} _snippets/file.mddirectives, the right-side "On this page" navigation displayed snippet headings at the top instead of respecting their document position, causing confusing navigation order.Root Cause
In the
GetAnchorsmethod inMarkdownFile.cs:Solution
Explore repository structure and understand the codebaseBuild the project and run tests to verify current functionalityAnalyze theGetAnchorsmethod inMarkdownFile.csIdentify root cause: snippet headings get line number 0 in sortingCreate a focused test that reproduces the issueFix the line number assignment for included snippetsVerify the fix resolves the ordering issueRun tests to ensure no regressionsAdd comprehensive tests for different include positionsAdd tests with stepper components that also contribute to TOCRefactor tests to use numbered words for clear ordering verificationChanges Made
Modified the
GetAnchorsmethod to:IncludeBlockdirectives and their snippetsTesting Coverage
Added comprehensive tests covering five scenarios using numbered words (One, Two, Three, etc.) for easy verification:
All tests verify that the table of contents respects document order regardless of where include directives are positioned and whether stepper components are involved. The numbered headings make it immediately apparent that the ordering is correct (One, Two, Three, Four, Five, Six, Seven, Eight, etc.).
Verification
Created manual test showing the fix works:
Before Fix:
After Fix:
Now snippet headings appear at the position where the include directive is located in the main document, preserving the intended document order for both regular headings and stepper components.
Fixes #1880.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.