-
-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting more kramdown options. #1201
Conversation
👍 |
|
||
def symbolize_keys! | ||
keys.each do |key| | ||
self[(key.to_sym rescue key) || key] = delete(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What strange Ruby creature is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ripped from Rails core extensions. There's a note in my comment in #1095 :)
So, the more you stare at the function the more awesome it becomes. The magic comes from delete(key) because it actually returns the value of what it deletes. So, returning the value from what we delete now sets the symbolized key to that value! BRILLIANT! |
An additional test to verify passthrough of additional options plus a doc update would be nice to have here. |
Agreed, Here's the issue I have though. For my test do I need to pass every single possible kramdown item in the hash? We allow all of them so it only seems right. What do you think @mattr-? |
I don't think we need every possible option. Ultimately, we just need to verify the they're in the hash properly. It's kramdown's responsibility to handle its own options. On Fri, Jun 28, 2013 at 6:07 PM, Zach notifications@github.com wrote:
|
@@ -26,7 +26,7 @@ def convert(content) | |||
# not using coderay | |||
base_kramdown_configs | |||
end | |||
Kramdown::Document.new(content, kramdown_configs).to_html | |||
Kramdown::Document.new(content, @config["kramdown"].symbolize_keys).to_html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could delete all the other code in that method and the base_kramdown_configs
method then, couldn't you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it again, will this work with the nested config hash (coderay
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it'd have to deep-symbolize if that is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, where are coderay options used in kramdown? http://kramdown.rubyforge.org/options.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, where are coderay options used in kramdown?
❓ Kramdown wants the coderay options directly in its option hash (with symbol keys, of course), but jekyll seems to have historically chosen to have them in a nested coderay
hash in _config.yml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering where in the Kramdown documentation these Coderay options are mentioned and why Kramdown wants them in their array of options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where in the Kramdown documentation these Coderay options are mentioned
On the site you linked, starting from option 3, coderay_bold_every
.
I don't know Kramdown but it seems like another code highlighting system:
enable_coderay
Use coderay for syntax highlighting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm literally blind. Sorry about that :)
So, Here is what I am going to do gents:
Then I will run the test suite (lol @ my spelling mistake) again to see if anything has broken. Sound good? |
Sounds good to me. Thanks! |
Yup. 👍 |
@zachgersh I'd love to include this in the v1.1 release if you have time today or tomorrow to finish this up? |
I will have this done for you tomorrow! Apologies for the delay. On Jul 12, 2013, at 11:31 AM, Parker Moore notifications@github.com wrote:
|
No problem! :D |
@zachgersh Wait, why are we removing the |
Okay. I will leave it in. On Jul 13, 2013, at 9:36 AM, Parker Moore notifications@github.com wrote:
|
If it's poor organizing then we can move thing around but if not, it would be wonderful if you left it in. Thank you!! ❤️ |
It seems it is not used anymore in the code for this PR, that's why I had suggested so. |
I mean, it's called twice, but the result ( |
Hey @maul-esel could you jump in the irc channel? I actually wanted to run a test by you. I discarded it without ill effect including the coderay bit as well. |
@maul-esel If it's not used then we don't need it, ya! But we need to keep the current configuration options absolutely the same (in terms of coderay, etc) so we'll need at least the coderay stuff,. |
@parkr IRC please :) |
Hey @mattr- and @parkr, I am having some issues actually trying to test this properly. Also I found that we are already testing kramdown options here: https://github.com/mojombo/jekyll/blob/master/test/test_kramdown.rb So what I decided on was deep_merging in a new option in: remove_span_html_tags Then I try to run this sort of test
I was hoping that the kramdown would strip the If one of you is around on IRC tonight I think I could wrap this up fairly quickly but I need some help. |
Sorry, I missed this. I'm not usually around IRC until 9pm Central Time or so, which is usually sometime early morning for all y'all. 😀 |
I 👍 this for the code, but I 😡 at @zachgersh's choice of options to test. the |
Looking at this, there really aren't many more options to test: http://kramdown.rubyforge.org/converter/html.html Our original test was already pretty good :) I am about to commit a few slight changes to this. |
…s we don't support.
Supporting more kramdown options.
@@ -13,7 +13,7 @@ def initialize(config) | |||
|
|||
def convert(content) | |||
# Check for use of coderay | |||
kramdown_configs = if @config['kramdown']['use_coderay'] | |||
if @config['kramdown']['use_coderay'] | |||
base_kramdown_configs.merge({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, forgot a call to the method
Gasp! I'm not 😡 at @zachgersh's choice of option, but rather at Kramdown's weird implementation of stripping HTML tags from documents and the fact that the option doesn't work with the HTML converter it provides. Sorry @zachgersh 😭 |
Getting the conversation started on #1095. Taking @parkr's suggestion.