Skip to content
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

Ensure colons do not break titles #39

Merged
merged 4 commits into from
Mar 17, 2016

Conversation

djds23
Copy link
Contributor

@djds23 djds23 commented Mar 15, 2016

When titles have colons in them, it breaks the liquid template.
This encapsulates the titles in string literals if the user
wants a title with a colon in it.

Closes #38

When titles have colons in them, it breaks the liquid template.
This encapsulates the titles in string literals if the user
wants a title with a colon in it.

Closes jekyll#38
@djds23 djds23 force-pushed the make-title-string-literal branch from a1a9d3d to b3e656c Compare March 15, 2016 04:27
@@ -13,8 +13,18 @@ def content
<<-CONTENT.gsub /^\s+/, ''
---
layout: #{params.layout}
title: #{params.title}
title: #{yaml_clean_title}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we could do this instead?

YAML.dump({
  "layout" => params.layout,
  "title" => params.title
})

That will create YAML and escape everything properly. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a far more elegant solution! thanks for the tip.

@djds23
Copy link
Contributor Author

djds23 commented Mar 15, 2016

@parkr it looks like using YAML#dump breaks support for >2.0 versions of ruby. Would you prefer I put logic to check the ruby runtime and use my previous method for versions >2.0? Or would you like to break support for >1.9 in the next release?

Thanks again for taking time with my PR.

@djds23
Copy link
Contributor Author

djds23 commented Mar 15, 2016

Apparently in ruby 1.9, the string is interpreted as a non-specific tag.

@djds23
Copy link
Contributor Author

djds23 commented Mar 15, 2016

@parkr since the non-specific tag is still valid YAML, I just updated the spec to only ensure that the title is wrapped in quotes, not check that the syntax is exactly the same.

@parkr
Copy link
Member

parkr commented Mar 16, 2016

Or would you like to break support for >1.9 in the next release?

Let's remove support for v1.9. We don't support it in Jekyll and it's EOL'd so I'm fine with this. Would you ensure you get the correct title in the YAML and that it parses properly? Thanks!

@djds23
Copy link
Contributor Author

djds23 commented Mar 17, 2016

@parkr I reverted the tests so they test for the exact string. This breaks tests on >1.9, but is better coverage. I think this is ready to 🚢 !

@parkr
Copy link
Member

parkr commented Mar 17, 2016

@jekyllbot: merge

jekyllbot added a commit that referenced this pull request Mar 17, 2016
@jekyllbot jekyllbot merged commit 1eda1aa into jekyll:master Mar 17, 2016
jekyllbot added a commit that referenced this pull request Mar 17, 2016
@jekyll jekyll locked and limited conversation to collaborators Apr 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jekyll post creates invalid YAML header for title with colon
3 participants