rust-lang / rust-lang/mdBook

Sidebar header navigation renders empty anchor when heading is a Markdown link

Open
#3,126 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
22.2k
Forks
1.9k
Avg merge
2d 21h
Merged PRs (30d)
12

Description

Problem

A heading is a Markdown link causes the sidebar header navigation item to render as an empty anchor.

For example, a heading like:

## [fzf](https://github.com/junegunn/fzf)

can produce sidebar HTML like:

<li class="header-item expanded">
  <span class="chapter-link-wrapper">
    <a href="#fzf" class="header-in-summary current-header"></a>
  </span>
</li>

The <a> is present, but it has no text content, so the sidebar entry appears blank.

The sidebar generates a matching anchor element for the heading, but the rendered text content is empty.

See https://sigoden.github.io/mynotes/collections/cli.html for an example.

Image
Steps
  1. run mdbook init
  2. modify src/chapter_1.md
# Chapter 1

## [fzf](https://github.com/junegunn/fzf)

An interactive filter program for any kind of list.

## [rg](https://github.com/BurntSushi/ripgrep)

Fast line-oriented search tool.
  1. run mdbook serve
Possible Solution(s)

The sidebar header navigation should display the heading text, even if the heading is a Markdown link.

At minimum, headings with links should not produce an empty sidebar entry.

Notes

No response

Version
mdbook v0.5.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with mdbook init, the sample heading in src/chapter_1.md, and mdbook serve. Start by inspecting the generated sidebar entry for the Markdown-linked heading; done when the sidebar displays the heading text instead of an empty anchor.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, rust
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.