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

Sidebar doesn't add a space character when item is split in two lines #1218

Closed
ericonr opened this issue May 12, 2020 · 2 comments · Fixed by #1291
Closed

Sidebar doesn't add a space character when item is split in two lines #1218

ericonr opened this issue May 12, 2020 · 2 comments · Fixed by #1291
Labels
A-Summary Area: The summary page, organization of pages.

Comments

@ericonr
Copy link
Contributor

ericonr commented May 12, 2020

Hey there! We are using mdBook for the documentation for Void Linux, here: https://docs.voidlinux.org/.

If you look at the sidebar, under graphics drivers, there's a "NVIDIAOptimus" item. This item is specified in SUMMARY.md as:

- [NVIDIA
   Optimus](link.)

It is split in two lines due to our linting, where lines are constrained to 80 columns. The original source can be found in https://raw.githubusercontent.com/void-linux/void-docs/master/src/SUMMARY.md . GitHub formatting, when displaying this file (here), displays it correctly as "NVIDIA Optimus".

This seems to be a bug when creating the sidebar. I haven't noticed anything similar with normal files.

Thanks!

@ericonr
Copy link
Contributor Author

ericonr commented Jul 29, 2020

This seems to be an issue with pulldown-cmark, I think. At least, most of the processing seems to happen in the code below, unless the issue is with how mdbook generates name...

            if !self.no_section_label {
                // Section does not necessarily exist
                if let Some(section) = item.get("section") {
                    out.write("<strong aria-hidden=\"true\">")?;
                    out.write(&section)?;
                    out.write("</strong> ")?;
                }
            }

            if let Some(name) = item.get("name") {
                // Render only inline code blocks

                // filter all events that are not inline code blocks
                let parser = Parser::new(name).filter(|event| match *event {
                    Event::Code(_) | Event::Html(_) | Event::Text(_) => true,
                    _ => false,
                });

                // render markdown to html
                let mut markdown_parsed_name = String::with_capacity(name.len() * 3 / 2);
                html::push_html(&mut markdown_parsed_name, parser);

                // write to the handlebars template
                out.write(&markdown_parsed_name)?;
            }

            if path_exists {
                out.write("</a>")?;
            }

@ericonr
Copy link
Contributor Author

ericonr commented Jul 29, 2020

It is how name is generated! Adding a println!("{}", name); there prints NVIDIAOptimus, so pulldown-cmark is doing the right think with what it gets.

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this issue Aug 30, 2020
Summary items that had their name split into two lines ended up with the
last word of one line and the first word of the next line glued
together, since a space wasn't added.

Added test case for it.

Fixes rust-lang#1218
rubenmoor pushed a commit to rubenmoor/mdBook that referenced this issue Aug 5, 2022
Summary items that had their name split into two lines ended up with the
last word of one line and the first word of the next line glued
together, since a space wasn't added.

Added test case for it.

Fixes rust-lang#1218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Summary Area: The summary page, organization of pages.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants