Repository navigation
Replace Slugify.Core with our own slug method - #4892
Merged
Merged
Conversation
Slugify.Core 5.x rejects null input and blocked the package upgrade. The slug rules now live in StringExtensions.Slugify, so anchors, heading ids and changelog links no longer change with a package bump. A golden file holds the 4.0.1 output for every heading in docs/ plus edge cases, and a test checks the new method against it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
akira28
approved these changes
Nov 17, 2026
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4892/ |
Tabs, newlines and no-break spaces become a dash, as in Slugify.Core 4.0.1. Slugify.Core 5.x drops them, so the comment says where we differ. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
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.
Slugs now come from our own
Slugifyextension inElastic.Documentation, and theSlugify.Corepackage is gone. Output is identical to 4.0.1.Affects: Authoring, Release notes
Prompt summary: Implement #4835: replace
Slugify.Corewith a small slug method that defines the rules we depend on, pin them with tests written against 4.0.1, move the callers over and drop the package reference.Why
Slugify.Core5.x rejects null input, so the upgrade did not compile without a workaround that hid a behaviour change. Slugs feed anchors, heading ids and changelog links, so a silent change breaks links. #4834 holds the package at 4.0.1.What
One slug method
StringExtensions.Slugifytrims, removes diacritics, lower-cases, turns whitespace runs into one-, keeps onlya-z 0-9 - _ .and collapses repeated dashes. Null and blank input give an empty string.Callers
All
.Slugify()callers already use this method.LatestDocsetGeneratornow calls it in place ofSlugHelper.GenerateSlug. The package reference and version are removed. The private slug helper inChangelogFileWriteris a different algorithm (it truncates) and stays.Tests that pin the rules
slugify-4.0.1.golden.tsvholds 4.0.1 output for every heading indocs/plus edge cases. A test checks the new method against it, and a table test states the rules. I also compared both implementations on about 220,000 random anddocs/strings with zero differences.Whitespace differs from Slugify.Core 5.x
Any Unicode whitespace (tab, newline, no-break space) becomes a dash, as in 4.0.1. Upstream
mainand 5.x replace only a plain space and drop the rest, soa<tab>bgivesa-bhere andabthere. I kept 4.0.1 so published anchors do not change. For every other input, this method and 5.2.0 agree on about 148,000 strings. TheSlugifydoc comment and a test state the rule.Verify
dotnet test --project tests/Elastic.Documentation.TestsChanging the allowed characters in
IsSlugCharmakes the golden test fail.