Skip to content
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

[2.x] Normalize Markdown heading identifiers #2059

Merged
merged 23 commits into from
Dec 7, 2024

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva 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.

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.

@caendesilva caendesilva changed the title [2.x] Normalize markdown heading identifiers [2.x] Normalize Markdown heading identifiers Dec 7, 2024
@caendesilva caendesilva force-pushed the normalize-markdown-heading-identifiers branch from 3dfcdf7 to 50f89f8 Compare December 7, 2024 21:44
@caendesilva caendesilva merged commit 0a6bbfa into new-asset-system Dec 7, 2024
12 checks passed
@caendesilva caendesilva deleted the normalize-markdown-heading-identifiers branch December 7, 2024 21:51
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.

1 participant