Conversation
|
Hello @alextsui05 from a first-pass, it looks like you're calling That said, from the failing CI logs, it looks like the intended results are being delivered, but for the maintainers to accept this, they'd like to have the tests passing and have this change documented because suddenly users of the |
Which makes this a major change rather than an enhancement, correct? |
As of now, yes, but if the author proposes a new mode altogether, then it can still be an |
|
@alextsui05 You'll need to make a couple of changes:
|
Gemfile
Outdated
|
|
||
| # Dependency of jekyll-mentions. RubyGems in Ruby 2.1 doesn't shield us from this. | ||
| gem "activesupport", "~> 4.2", :groups => [:test_legacy, :site] if RUBY_VERSION < "2.2.2" | ||
| gem 'activesupport', '~> 4.2', :groups => [:test_legacy, :site] if RUBY_VERSION < "2.2.2" |
There was a problem hiding this comment.
Our Rubocop config is set to double quotes
|
I realized The more I think about it, maybe it would be better for compatibility + clearer to define a new mode that is more explicit about what it does -- maybe I'll make another pass at the code at the end of the day to address the style issues too. Thanks for the help. |
|
I updated the PR to make it clear that we are adding a new |
lib/jekyll/utils.rb
Outdated
| # See Utils#slugify for a description of the character sequence specified | ||
| # by each mode. | ||
| private | ||
| def replace_character_sequence_with_hyphen(string, mode:) |
There was a problem hiding this comment.
not a big fan of the long name :replace_character_sequence_with_hyphen but its a private method and the name expresses the method's intention.. so its okay I guess..
But, how about making the :default mode the default parameter?
private
def replace_character_sequence_with_hyphen(string, mode: "default")
replaceable_char =
case mode
when "raw"
SLUGIFY_RAW_REGEXP
when "pretty"
# "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL
# and is allowed in both extN and NTFS.
SLUGIFY_PRETTY_REGEXP
when "ascii"
# For web servers not being able to handle Unicode, the safe
# method is to ditch anything else but latin letters and numeric
# digits.
SLUGIFY_ASCII_REGEXP
else
SLUGIFY_DEFAULT_REGEXP
end
string.gsub(replaceable_char, "-")
end(and effectively reduce the total no.of case branches`)
ghost
left a comment
There was a problem hiding this comment.
LGTM but i like @ashmaroli's suggestion
DirtyF
left a comment
There was a problem hiding this comment.
La France 🇫🇷 🥖 🧀 thanks you for this new latin mode @alextsui05 ❤️❤️ ❤️
|
I took @ashmaroli 's advice and simplified the switch statement. Thanks all for the reviews and help! |
|
@alextsui05 Thank you very much! This is already an awesome Wanna take it to a higher level? On a side-note, if you've the time, you can open a new PR documenting the |
mattr-
left a comment
There was a problem hiding this comment.
This is looking great! Thanks for your work on this!
I do have two small changes that I request you make before I feel this is ready to merge.
| # slugify("The _config.yml file", "ascii") | ||
| # # => "the-config.yml-file" | ||
| # | ||
| # slugify("The _config.yml file", "latin") |
There was a problem hiding this comment.
I think it would be better to see the example here demonstrate the difference between the ascii mode and the latin mode. This will make it clearer as to why the latin mode exists.
There was a problem hiding this comment.
@mattr- Yeah, I thought so, too. To really demonstrate the difference, the input string would need an accented character, but when I tried that, one of the builds failed with a note about non-ASCII characters disallowed in comments. I would point out the failed build but I'm not sure how to go through the build history for this PR in TravisCI.
|
|
||
| # Strip according to the mode | ||
| slug = string.gsub(re, "-") | ||
| slug = replace_character_sequence_with_hyphen(string, :mode => mode) |
There was a problem hiding this comment.
Using the symbol syntax would be better here, so that you're consistent with the rest of the codebase.
mode: modeThere was a problem hiding this comment.
@mattr- Another style error in the build came up here as well, something about using hash rocket syntax, so I wrote it this way.
|
Related to my above review comment, I would prefer that the documentation work for the |
|
@mattr- Thanks, I'll update the documentation in the |
|
@alextsui05 If making those changes would cause the build to fail, then let's not do those right now. I think that's on us as maintainers to fix those. 😃 Looking forward to seeing the new documentation and getting this merged soon! Thanks! |
|
I think its best that you make only changes related to the |
|
@mattr- I just pushed a documentation update that includes a description of the new I posted screenshots on the main body of the PR for the sections that changed. Once that's been finalized, I'll also update the table in the link @ashmaroli posted in an earlier comment. |
@alextsui05 Don't worry about it. The "table" has already been updated with your latest commit.. |
again, that should be handled in a separate PR.. |
|
Okay, let me split out the |
Please don't. That's just churn for no good reason. |
pathawks
left a comment
There was a problem hiding this comment.
Thanks for all the work you put into this! Really appreciate all the polish 👍
😆 |
@ashmaroli Sorry, I remembered the part about documenting ascii mode but forgot the part about in a new PR (this gets me at work, too). I'll keep it in mind for the next PR! |
|
I see no reason for the appveyor build to fail since all I did was merge in master so that we can merge this, so away we go! @jekyllbot: merge +minor @alextsui05 Thank you again for making the changes we've requested and congratulations on your first contribution to Jekyll! |


This is in response to #4623
To summarize the discussion in the above issue, trying to slugify strings with Swedish letters in them (accented characters in general) produced unexpected output.
asciimode does the job but drops accented characters, which is probably undesirable to some users. So we addlatinmode, which will transliterate accented characters to the ASCII equivalent.Example:
Changes
latinmode to be used as an option for#slugifyi18ngem to perform the transliterationlatinmode, and alsoasciimode, which existed but was not documentedDocumentation screenshots