Skip to content

Formatting of newlines in gitbook #805

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

Open
spier opened this issue Mar 27, 2025 · 6 comments
Open

Formatting of newlines in gitbook #805

spier opened this issue Mar 27, 2025 · 6 comments
Labels
🪲 Bug Bug - something that seems to be broken

Comments

@spier
Copy link
Member

spier commented Mar 27, 2025

gitbook is the tool that we use to host https://patterns.innersourcecommons.org.

gitbook has (recently) changed the way that newline characters (\n) in our markdown files are rendered.

Previously a single newline character did not generate a line break.
That meant that we could format our pattern files like below to allow for easier line-based commenting when reviewing patterns.

There's a central project that everyone depends on.
What a great candidate for InnerSource!
Unfortunately, the project has grown organically, with various contributions and additions slapped on haphazardly.

Recently gitbook made change in this rendering logic. Now such text in markdown is rendered exactly as shown i.e. each newline in the markdown also leads to a line break in the rendered HTML. This does not look great. See screenshot below.

Image

@spier spier added the 🪲 Bug Bug - something that seems to be broken label Mar 27, 2025
@dellagustin-sap
Copy link
Contributor

Maybe this was a bug introduced in Gitbook, this seems like a pretty noticeable change, but I could not find a record of it at https://gitbook.com/docs/changelog with a quick inspection.

@dellagustin-sap
Copy link
Contributor

@spier have you tried reaching out to their support?
https://gitbook.com/docs/help-center/further-help/how-do-i-contact-support

@spier
Copy link
Member Author

spier commented Jun 4, 2025

Yes. Their Support says that nothing was changed in their side. I am reasonably sure that that is not true but I cannot really prove it.

Even proving it would not help me. Rather we have to find a way to make the new rendering logic of gitbook work for us. Or switch to an entirely different solution but they would be a lot more work.

@dellagustin-sap
Copy link
Contributor

dellagustin-sap commented Jun 4, 2025

Not sure why I'm going through this rabbit hole instead of working on my to-do list, but hey sometimes that happens 😄 .
Their documentation on Markdown is quite meager - https://gitbook.com/docs/creating-content/formatting/markdown, but they do refer to CommonMark, os they are not reinventing the wheel.
CommonMark states (https://spec.commonmark.org/0.31.2/#soft-line-breaks):

A regular line ending (not in a code span or HTML tag) that is not preceded by two or more spaces or a backslash is parsed as a softbreak. (A soft line break may be rendered in HTML either as a line ending or as a space. The result will be the same in browsers. In the examples here, a line ending will be used.)
...
A conforming parser may render a soft line break in HTML either as a line ending or as a space.
A renderer may also provide an option to render soft line breaks as hard line breaks.

I inspected the page:

Screenshot showing the source of the page for the Maturity Model pattern on the book, with the Problem paragraph, showing that soft line breaks are used

They are conforming with Common Mark. The browser should be rendering the soft breaks as a spaces.
I did not find why it isn't (maybe some front end / CSS change?).

P.S.: While searching for this I learned the term "Semantic Line Breaks":

@dellagustin-sap
Copy link
Contributor

I stop here, but I think this is the "culprit", the CSS style white-space-collapse set to preserve, coming from the class whitespace-pre-wrap from an upper div.

Screenshot of the DevTools for the Maturity Model page showing the computed style white-space-collapse for the p element for the Problem section

@spier
Copy link
Member Author

spier commented Jun 4, 2025

Great debugging @dellagustin-sap . Thank you!

I had approached it from the user perspective first, and compared the current rendering with older version from waybackmachine.

e.g. for the Core Team pattern: current and old (2025-01-24)

I will point gitbook Support to this conversation here. Maybe it helps them to debug the issue on their end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 Bug Bug - something that seems to be broken
Projects
None yet
Development

No branches or pull requests

2 participants