Skip to content

Replace Slugify.Core with our own slug method - #4892

Merged
Mpdreamz merged 2 commits into
mainfrom
feature/replace-slugify-own-slug
Nov 17, 2026
Merged

Mpdreamz merged 2 commits into
mainfrom
feature/replace-slugify-own-slug

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Slugs now come from our own Slugify extension in Elastic.Documentation, and the Slugify.Core package is gone. Output is identical to 4.0.1.

Affects: Authoring, Release notes

Prompt summary: Implement #4835: replace Slugify.Core with 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.Core 5.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.Slugify trims, removes diacritics, lower-cases, turns whitespace runs into one -, keeps only a-z 0-9 - _ . and collapses repeated dashes. Null and blank input give an empty string.

Callers

All .Slugify() callers already use this method. LatestDocsetGenerator now calls it in place of SlugHelper.GenerateSlug. The package reference and version are removed. The private slug helper in ChangelogFileWriter is a different algorithm (it truncates) and stays.

Tests that pin the rules

slugify-4.0.1.golden.tsv holds 4.0.1 output for every heading in docs/ 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 and docs/ 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 main and 5.x replace only a plain space and drop the rest, so a<tab>b gives a-b here and ab there. 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. The Slugify doc comment and a test state the rule.

Verify

dotnet test --project tests/Elastic.Documentation.Tests

Changing the allowed characters in IsSlugChar makes the golden test fail.

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>
@github-actions

Copy link
Copy Markdown
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>
@Mpdreamz
Mpdreamz merged commit 85c3463 into main Nov 17, 2026
43 of 44 checks passed
@Mpdreamz
Mpdreamz deleted the feature/replace-slugify-own-slug branch November 17, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants