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

Auto-generated title incorrect when not using Unix newline encoding (LF) #7156

Closed
6 of 7 tasks
andgeno opened this issue Apr 12, 2022 · 4 comments
Closed
6 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@andgeno
Copy link

andgeno commented Apr 12, 2022

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Page titles will be rendered incorrectly depending on which newline format has been chosen.

✔ Linux (LF): Works as expected. Text of the first Markdown header is displayed.
❌ Windows (CRLF): Original filename and text of the first Markdown header is displayed.
❌ macOS (CR): Original filename is displayed. It's also missing the "Hello" text.

Here is a repro repository:

https://github.com/andgeno/docusaurus-repro-newline-encoding-bug

See the second commit for the actual demo files involved.

Some screenshots:

image

image

image

image

Reproducible demo

https://github.com/andgeno/docusaurus-repro-newline-encoding-bug

Steps to reproduce

  • Create a new file and encode it Windows or macOS newline format.
  • Add a Markdown header to make the title look different / nicer than just the raw filename.
  • Visit page of that new file.
  • Page title will be rendered incorrectly.

Expected behavior

Titles should render the same in all cases.

Actual behavior

Titles render wrong depending on chosen newline format.

Your environment

  • Docusaurus version used: 2.0.0-beta.18

Self-service

  • I'd be willing to fix this bug myself.
@andgeno andgeno added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 12, 2022
@Josh-Cena
Copy link
Collaborator

Duplicate of #7044

@Josh-Cena Josh-Cena marked this as a duplicate of #7044 Apr 12, 2022
@Josh-Cena Josh-Cena added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs triage This issue has not been triaged by maintainers labels Apr 12, 2022
@Josh-Cena
Copy link
Collaborator

Also, I've never seen a text editor, macOS (unless you use a super old one) or anywhere else, that uses only CR for line breaks. TBF, you should always normalize line endings to LF.

@andgeno
Copy link
Author

andgeno commented Apr 12, 2022

The thing is that I've been banging my head for over an hour on this issue until I noticed something is wrong with the newline formatting. I'm using IntelliJ and it creates CRLF-encoded files while the example files created using Docusaurus are LF-encoded. The IDE is behaving correctly since I'm working on a Windows machine. So either Docusaurus should apply normalization on example files or handle other NL formats correctly.

EDIT:
Maybe I should clarify that I only seek proper support for LF/CRLF. CR is indeed an archaic newline format and probably not to be found anywhere anymore. I simply did a complete test on all possibilities once I noticed this issue and this included CR. ;-)

@Josh-Cena
Copy link
Collaborator

Yeah, it's an inconsiderate bug and already fixed in #7043. The reason why it's not caught is because our repo performs LF normalization and there's no test run on CRLF. But honestly, I feel like the very existence of CRLF is a bug in itself ;) Just saying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants