Hexo: The problem of anchor elements

Created on 27 Nov 2018  ·  4Comments  ·  Source: hexojs/hexo

Environment Info

Node version(node -v): v10.13.0

Your site _config.yml (Optional):

Your theme _config.yml (Optional):

Hexo and Plugin version(npm ls --depth 0):

For BUG

For question


hi, I try to create table of contents in a page. But hexo do not Convert capital letters to lowercase letters
in the "h3" or "a" label, so the table of contents can't find the anchor elements. For example:

this is the table of content:
- [Reference document](#reference-document)

this is the anchor elements:
I write it like this,
### Reference document
but it will be translated to it below,
<h3 id="Reference-document"><a href="#Reference-document" class="headerlink" title="Reference document"></a>Reference document</h3>
Please note "Reference-document" has capital letters . It is the problem that the table of content can't find the anchor elements.

So anybody has some solutions to solve it ? thanks.

For feature request

question

Most helpful comment

@YoshinoriN It works, reason 2 is the answer ! Thanks! Maybe the author should update the modifyAnchors setting:)

All 4 comments

modifyAnchors setting come in useful, if you are using hexo-renderer-marked.
In other ways, toc helper can create toc automatically.

@YoshinoriN Thanks for your help .
I installed hexo-renderer-marked. But it seems not work.
my hexo version is 3.8.0.
and I put the configuration in my _config.yml in the root directory of my hexo project, also I set modifyAnchors: "1" .
Could you give me some suggestion ? Thanks.

@leven87
OK. I came up with three reasons.

One

hexo-renderer-marked maybe can not use together other markdown renderer plugin. For example hexo-renderer-markdown-it.

Two

modifyAnchors setting seems have to specify integer. Maybe not work if string. So, you should write setting like modifyAnchors: 1.

I think documentation is not good.

Three

Hexo has chach data in db.json.
Please delete db.json and try again.

@YoshinoriN It works, reason 2 is the answer ! Thanks! Maybe the author should update the modifyAnchors setting:)

Was this page helpful?
0 / 5 - 0 ratings