private string Slugify(FillSlugContext slugContext)
        {
            _slugEventHandler.FillingSlugFromTitle(slugContext);

            if (!slugContext.Adjusted)
            {
                var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>\\]+");

                slugContext.Slug = disallowed.Replace(slugContext.Title, "-").Trim('-', '.');

                if (slugContext.Slug.Length > 1000)
                {
                    slugContext.Slug = slugContext.Slug.Substring(0, 1000).Trim('-', '.');
                }

                slugContext.Slug = StringExtensions.RemoveDiacritics(slugContext.Slug.ToLower());
            }

            _slugEventHandler.FilledSlugFromTitle(slugContext);

            return(slugContext.Slug);
        }
        private string Slugify(FillSlugContext slugContext)
        {
            _slugEventHandler.FillingSlugFromTitle(slugContext);

            if (!slugContext.Adjusted)
            {
                string stFormKD = slugContext.Title.ToLower().Normalize(NormalizationForm.FormKD);
                var    sb       = new StringBuilder();

                foreach (char t in stFormKD)
                {
                    // Allowed symbols
                    if (t == '-' || t == '_' || t == '~')
                    {
                        sb.Append(t);
                        continue;
                    }

                    UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(t);
                    switch (uc)
                    {
                    case UnicodeCategory.LowercaseLetter:
                    case UnicodeCategory.OtherLetter:
                    case UnicodeCategory.DecimalDigitNumber:
                        // Keep letters and digits
                        sb.Append(t);
                        break;

                    case UnicodeCategory.NonSpacingMark:
                        // Remove diacritics
                        break;

                    default:
                        // Replace all other chars with dash
                        sb.Append('-');
                        break;
                    }
                }

                slugContext.Slug = sb.ToString().Normalize(NormalizationForm.FormC);

                // Simplifies dash groups
                for (int i = 0; i < slugContext.Slug.Length - 1; i++)
                {
                    if (slugContext.Slug[i] == '-')
                    {
                        int j = 0;
                        while (i + j + 1 < slugContext.Slug.Length && slugContext.Slug[i + j + 1] == '-')
                        {
                            j++;
                        }
                        if (j > 0)
                        {
                            slugContext.Slug = slugContext.Slug.Remove(i + 1, j);
                        }
                    }
                }

                if (slugContext.Slug.Length > 1000)
                {
                    slugContext.Slug = slugContext.Slug.Substring(0, 1000);
                }

                slugContext.Slug = slugContext.Slug.Trim('-', '_', '.');
            }

            _slugEventHandler.FilledSlugFromTitle(slugContext);

            return(slugContext.Slug);
        }