Skip to content

Conversation

@emmadesilva
Copy link
Member

@emmadesilva emmadesilva commented Dec 7, 2024

This pull request modifies the heading identifier generation to improve how heading slugs/IDs are created. The key changes include:

  1. Replacing the simple Str::slug() method with a more robust makeIdentifier() method in the HeadingRenderer class.

  2. Adding more comprehensive normalization of heading text:

    • Transliterate non-ASCII characters
    • Replace certain special characters (e.g., '&' becomes 'and', '<' and '>' are removed)
    • Handle emojis by removing them
    • Normalize accented characters
    • Trim and clean up various edge cases
  3. Ensure the identifier works consistently across different types of input, including:

    • Special characters
    • Emojis
    • Accented characters
    • Non-Latin scripts
    • Headings with leading/trailing spaces
  4. Added comprehensive unit tests to verify the new identifier generation works correctly for a wide range of input scenarios.

The goal is creating more predictable and clean URL-friendly identifiers for headings in markdown documents, while maintaining readability and handling internationalization.

@codecov
Copy link

codecov bot commented Dec 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (3cc57cb) to head (50f89f8).
Report is 24 commits behind head on new-asset-system.

Additional details and impacted files
@@                 Coverage Diff                  @@
##             new-asset-system     #2059   +/-   ##
====================================================
  Coverage              100.00%   100.00%           
- Complexity               1931      1932    +1     
====================================================
  Files                     196       196           
  Lines                    5139      5141    +2     
====================================================
+ Hits                     5139      5141    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@emmadesilva emmadesilva changed the title [2.x] Normalize markdown heading identifiers [2.x] Normalize Markdown heading identifiers Dec 7, 2024
@emmadesilva emmadesilva force-pushed the normalize-markdown-heading-identifiers branch from 3dfcdf7 to 50f89f8 Compare December 7, 2024 21:44
@emmadesilva emmadesilva merged commit 0a6bbfa into new-asset-system Dec 7, 2024
8 checks passed
@emmadesilva emmadesilva deleted the normalize-markdown-heading-identifiers branch December 7, 2024 21:51
emmadesilva added a commit that referenced this pull request Dec 22, 2024
Want to match #2059, but that would change output so deferring to v2.
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