pub fn title_to_slug(title: &str) -> StringExpand description
Convert a bean title into a URL-safe kebab-case slug for use in filenames.
Algorithm:
- Trim whitespace
- Lowercase all characters
- Replace spaces with hyphens
- Remove non-alphanumeric characters except hyphens
- Collapse consecutive hyphens into single hyphen
- Remove leading/trailing hyphens
- Truncate to 50 characters
- Return “unnamed” if empty
§Examples
- “My Task” → “my-task”
- “Build API v2.0” → “build-api-v20”
- “Foo Bar” → “foo-bar”
- “Implement
bn showto render Markdown” → “implement-bn-show-to-render-markdown” - “Update Bean parser to read .md + YAML frontmatter” → “update-bean-parser-to-read-md-yaml-frontmatter”
- “My-Task!!!” → “my-task”
- “ Spaces “ → “spaces”
- “” (empty) → “unnamed”
- “a” (single char) → “a”