Adds Slugify(input string) string, which turns a piece of text into lowercase
ASCII letters, digits and single hyphens: safe for a URL path, a filename or a
fragment identifier.
This belongs here because anything that publishes a page, writes a file named
after a title or builds an anchor needs it, and it pairs with the existing FilterToAlnum, which removes separators entirely instead of keeping them as
word boundaries.
Things to know:
Characters outside ASCII are treated as separators, not folded to a nearest
ASCII relative, so "Grüße" becomes "gr-e" and a string of only non-ASCII text
becomes empty. Folding properly needs Unicode tables from golang.org/x/text, and this package should not take on a dependency for it.
The doc comment says so plainly, and there is a test for both cases.
A trailing separator produces no trailing hyphen: the hyphen is only written
once another usable character turns up.
Two different titles can slugify to the same string, so callers that need
uniqueness still have to handle collisions themselves.
The code is in a new file, slugify.go, so that the ten proposal branches do
not all conflict in the same place.
make test on this branch reports one failure, TestNowUnixMicro. That test
already fails on master and is unrelated to this change.
Model: opus-5
Adds `Slugify(input string) string`, which turns a piece of text into lowercase
ASCII letters, digits and single hyphens: safe for a URL path, a filename or a
fragment identifier.
This belongs here because anything that publishes a page, writes a file named
after a title or builds an anchor needs it, and it pairs with the existing
`FilterToAlnum`, which removes separators entirely instead of keeping them as
word boundaries.
Things to know:
- Characters outside ASCII are treated as separators, not folded to a nearest
ASCII relative, so "Grüße" becomes "gr-e" and a string of only non-ASCII text
becomes empty. Folding properly needs Unicode tables from
`golang.org/x/text`, and this package should not take on a dependency for it.
The doc comment says so plainly, and there is a test for both cases.
- A trailing separator produces no trailing hyphen: the hyphen is only written
once another usable character turns up.
- Two different titles can slugify to the same string, so callers that need
uniqueness still have to handle collisions themselves.
- The code is in a new file, `slugify.go`, so that the ten proposal branches do
not all conflict in the same place.
- `make test` on this branch reports one failure, `TestNowUnixMicro`. That test
already fails on `master` and is unrelated to this change.
Model: opus-5
clawbot
self-assigned this 2026-09-05 05:27:05 +02:00
Slugify lowercases text and keeps only ASCII letters and digits, turning every
run of other characters into a single hyphen with none left at either end.
Comes with a doc comment and table-driven tests. (closes#9)
Model: opus-5
sneak
merged commit 74b448851e into master2026-09-05 05:44:52 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Adds
Slugify(input string) string, which turns a piece of text into lowercaseASCII letters, digits and single hyphens: safe for a URL path, a filename or a
fragment identifier.
This belongs here because anything that publishes a page, writes a file named
after a title or builds an anchor needs it, and it pairs with the existing
FilterToAlnum, which removes separators entirely instead of keeping them asword boundaries.
Things to know:
ASCII relative, so "Grüße" becomes "gr-e" and a string of only non-ASCII text
becomes empty. Folding properly needs Unicode tables from
golang.org/x/text, and this package should not take on a dependency for it.The doc comment says so plainly, and there is a test for both cases.
once another usable character turns up.
uniqueness still have to handle collisions themselves.
slugify.go, so that the ten proposal branches donot all conflict in the same place.
make teston this branch reports one failure,TestNowUnixMicro. That testalready fails on
masterand is unrelated to this change.Model: opus-5