docsify: The first h1 header is ignored in sidebar

Bug Report

As the title suggests, the first h1 markdown header is ignored in sidebar.

Steps to reproduce

Let’s say we have two h1 headers ‘a’ and ‘b’, for each one of them, we have three h2 sub-headers a.1, a.2, a.3, and b.1, b.2, b.3 respectively. The output will be as if a.1, a.2, a.3, and b are h1 headers and b.1, b.2, b.3 as h2 sub-headers.

What is current behaviour

In other words, the input is :

# a
## a.1
## a.2
## a.3
# b
## b.1
## b.2
## b.3

and the generated sidebar looks like the following :

# a.1
# a.2
# a.3
# b
## b.1
## b.2
## b.3

a is ignored and all of its content (sub-headers) levels up!

What is the expected behaviour

The expected behavior is to have the same hierarchy as the original input.

Other relevant information

However, I have found a hack to fix this, just add an empty first header to replace the one ignored. i.e. the input becomes :

#  
# a
## a.1
## a.2
## a.3
# b
## b.1
## b.2
## b.3
  • Your OS: Ubuntu 18.04
  • Node.js version: v8.10.0
  • npm/yarn version: npm 6.12.0
  • Browser version: Google Chrome 80.0.3987.132
  • Docsify version: docsify-cli 4.4.0
  • Docsify plugins: Copy to Clipboard + Language Highlight (Python) + Full Text Search

Please create a reproducible sandbox

I tried to reproduce the same case on codesandbox.io but I couldn’t, this is an error related to their website not to docsify.

Mention the docsify version in which this bug was not present (if any)

I’m using one version only, the latest one.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

The issue also happened with me. As @stoufa shown, adding the #   before the first header hides the problem.

Your OS: Ubuntu 18.04.5 LTS Node.js version: v12.18.4 npm/yarn version: npm 6.14.6 Browser version: Edge Version 85.0.564.63 (Official build) (64-bit) Docsify version: docsify-cli 4.4.1 Docsify plugins: none

I create a initialization docsify project (docsify init ./docs).
and edit the README. md


# a
## a.1
## a.2
## a.3
# b
## b.1
## b.2
## b.3

the sidebar rendered correctly.

so, I think u could create a simple demo likes this. if the bug isn’t reproducible, I guess there may have others configurations/content get it broken. otherwise we could investigate the environment problems.