def slugify(string, mode: nil, cased: false)
      mode ||= "default"
      return nil if string.nil?

      unless SLUGIFY_MODES.include?(mode)
        return cased ? string : string.downcase
      end

      # Drop accent marks from latin characters. Everything else turns to ?
      if mode == "latin"
        I18n.config.available_locales = :en if I18n.config.available_locales.empty?
        string = I18n.transliterate(string)
      end

      slug = replace_character_sequence_with_hyphen(string, :mode => mode)

      # Remove leading/trailing hyphen
      slug.gsub!(%r!^\-|\-$!i, "")

      slug.downcase! unless cased
      Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty?
      slug
    end
def slugify(string, mode: nil, cased: false)
      mode ||= "default"
      return nil if string.nil?

      unless SLUGIFY_MODES.include?(mode)
        return cased ? string : string.downcase
      end

      # Drop accent marks from latin characters. Everything else turns to ?
      if mode == "latin"
        I18n.config.available_locales = :en if I18n.config.available_locales.empty?
        string = I18n.transliterate(string)
      end

      slug = replace_character_sequence_with_hyphen(string, :mode => mode)

      # Remove leading/trailing hyphen
      slug.gsub!(%r!^\-|\-$!i, "")

      slug.downcase! unless cased
      Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty?
      slug
    end
rubocop: enable PredicateName
 Slugify a filename or title.

 string - the filename or title to slugify
 mode - how string is slugified
 cased - whether to replace all uppercase letters with their
 lowercase counterparts

 When mode is "none", return the given string.

 When mode is "raw", return the given string,
 with every sequence of spaces characters replaced with a hyphen.

 When mode is "default" or nil, non-alphabetic characters are
 replaced with a hyphen too.

 When mode is "pretty", some non-alphabetic characters (._~!$&'()+,;=@)
 are not replaced with hyphen.

 When mode is "ascii", some everything else except ASCII characters
 a-z (lowercase), A-Z (uppercase) and 0-9 (numbers) are not replaced with hyphen.

 When mode is "latin", the input string is first preprocessed so that
 any letters with accents are replaced with the plain letter. Afterwards,
 it follows the "default" mode of operation.

 If cased is true, all uppercase letters in the result string are
 replaced with their lowercase counterparts.

 Examples:
   slugify("The _config.yml file")
   # => "the-config-yml-file"

   slugify("The _config.yml file", "pretty")
   # => "the-_config.yml-file"

   slugify("The _config.yml file", "pretty", true)
   # => "The-_config.yml file"

   slugify("The _config.yml file", "ascii")
   # => "the-config-yml-file"

   slugify("The _config.yml file", "latin")
   # => "the-config-yml-file"

 Returns the slugified string.