Skip to content

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

Description

@sigoden

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions