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

quote handling in front matter title incorrect #5171

Closed
dret opened this issue Jul 31, 2016 · 5 comments
Closed

quote handling in front matter title incorrect #5171

dret opened this issue Jul 31, 2016 · 5 comments

Comments

@dret
Copy link

dret commented Jul 31, 2016

https://github.com/dret/webconcepts/blob/gh-pages/specs/IETF/RFC/6271.md uses jekyll front matter and has quotes in the title. it thus escapes those quotes. http://webconcepts.info/specs/IETF/RFC/6271 is the web view of that. while the HTML body//h1 title is correct, the HTML head//title incorrectly escapes the escaped quote. this results in browser displaying the page title incorrectly, for example in tabs or in the history.
steps to reproduce are to simply create a jekyll page with an escaped quote in a quoted title in the front matter. i see this bug on my locally installed jekyll 3.1.6, as well as on github.

@jake-low
Copy link

jake-low commented Jul 31, 2016

Hi @dret, thanks for the bug report!

I wasn't able to reproduce this on my own site, so I cloned yours and poked around. I think the issue is that your head.html include, which comes from the theme you're using (jekyll/minima) uses an escape filter when setting the page title.

<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>

This takes the ampersands in the page title and escapes them again, causing the mangled title you're seeing.

The minima theme is doing this so that you don't have to; it's designed so that you can use HTML-unsafe characters in your title strings without worry. But since you're escaping "manually" it escapes your escapes, which isn't what you want.

I think your best bet is to write your titles as plain, un-escaped strings, and let Jekyll take care of escaping them where necessary. In this case, you could make this change:

- title:  "The Atom &#34;deleted-entry&#34; Element"
+ title:  "The Atom \"deleted-entry\" Element"

Or even this:

- title:  "The Atom &#34;deleted-entry&#34; Element"
+ title:  The Atom "deleted-entry" Element

... since Liquid YAML doesn't require quotes around strings.

Hope this is helpful!

@dret
Copy link
Author

dret commented Jul 31, 2016

On 2016-07-30 18:41, Jake Low wrote:

Hi @dret https://github.com/dret, thanks for the bug report!

and thanks a lot for the detailed response!

  • title: "The Atom "deleted-entry" Element"
  • title: "The Atom "deleted-entry" Element"

dret/webconcepts@b5efe07
is doing this and seems to work. thanks for the suggestion.

  • title: "The Atom "deleted-entry" Element"
  • title: The Atom "deleted-entry" Element

this did not work (i would have preferred it) because it created some
problems with other characters in titles. but having one working
solution definitely is good enough. thanks!

@parkr
Copy link
Member

parkr commented Aug 1, 2016

Glad you got this sorted! We're at the mercy of Liquid and YAML here, sadly. :/

@parkr parkr closed this as completed Aug 1, 2016
@dret
Copy link
Author

dret commented Aug 1, 2016

i guess that's what you get yourself into when you happily mix markup languages a la YAML and HTML and MD. thanks for your help on this one!

@parkr
Copy link
Member

parkr commented Aug 2, 2016

@dret happily! and thanks to @jake-low 😄

@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants