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

Don't use quotes for user-entered YAML entries #305

Merged
merged 2 commits into from
Sep 6, 2019
Merged

Conversation

SamLau95
Copy link
Collaborator

@SamLau95 SamLau95 commented Sep 6, 2019

Because we used to wrap page title entries with quotes in YAML
front-matter, pages with a quote in the name would cause Jekyll to error
out (like this page titled "What's in a name?").

This commit uses YAML Block Scalars to give users the greatest
flexibility when naming book sections. Section names can now contain
single quotes, double quotes, and colons.

To test this:

  1. I edited jupyter_book/book_template/_data/toc.yml, changing the
    page titled Jupyter notebooks to "Sam's Cool Title: Notebooks!".
    I verified that building the website does not break at either
    jupyter-book build or the jekyll build step.
  2. I opened http://127.0.0.1:4001/jupyter-book/features/notebooks.html
    and verified that the sidebar had the updated title.
  3. I opened http://127.0.0.1:4001/jupyter-book/features/hiding.html and
    verified that the previous page button at the bottom of the page had
    Sam's Cool Title: Notebooks! as the previous page's title.

Because we used to wrap page title entries with quotes in YAML
front-matter, pages with a quote in the name would cause Jekyll to error
out ([like this page titled "What's in a name?"][1]).

This commit uses [YAML Block Scalars][2] to give users the greatest
flexibility when naming book sections. Section names can now contain
single quotes, double quotes, and colons.

To test this:

1. I edited `jupyter_book/book_template/_data/toc.yml`, changing the
   page titled `Jupyter notebooks` to `"Sam's Cool Title: Notebooks!"`.
   I verified that building the website does not break at either
   `jupyter-book build` or the `jekyll build` step.
2. I opened http://127.0.0.1:4001/jupyter-book/features/notebooks.html
   and verified that the sidebar had the updated title.
3. I opened http://127.0.0.1:4001/jupyter-book/features/hiding.html and
   verified that the previous page button at the bottom of the page had
   `Sam's Cool Title: Notebooks!` as the previous page's title.

[1]: https://www.textbook.ds100.org/ch/01/lifecycle_students_3.html
[2]: http://blogs.perl.org/users/tinita/2018/03/strings-in-yaml---to-quote-or-not-to-quote.html
@choldgraf
Copy link
Collaborator

One small nit to add a comment for context in the future, then I think this looks good to me!

@SamLau95 SamLau95 merged commit 8e0af85 into master Sep 6, 2019
@SamLau95 SamLau95 deleted the unquote-titles branch September 6, 2019 18:35
@choldgraf choldgraf added the bug Something isn't working label Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants