Closed noraj closed 6 years ago
So I uninstalled hexo-renderer-markdown-it
and installed hexo-renderer-markdown-it-plus
and I also installed manually markdown-it-toc-and-anchor
.
So my package.json is:
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.4.4"
},
"dependencies": {
"hexo": "^3.4.4",
"hexo-deployer-git": "^0.3.1",
"hexo-generator-archive": "^0.1.5",
"hexo-generator-category": "^0.1.3",
"hexo-generator-feed": "^1.2.2",
"hexo-generator-json-content": "^3.0.1",
"hexo-generator-tag": "^0.2.0",
"hexo-i18n": "^0.2.1",
"hexo-pagination": "^0.1.0",
"hexo-renderer-ejs": "^0.3.1",
"hexo-renderer-markdown-it-plus": "^1.0.3",
"hexo-renderer-stylus": "^0.3.3",
"hexo-server": "^0.3.1",
"hexo-sliding-spoiler": "^1.1.6",
"hexo-tag-asciinema": "0.0.1",
"hexo-tag-bootstrap": "^0.1.2",
"markdown-it-toc-and-anchor": "^4.1.2"
}
}
And my _config.yml contains:
# Markdown-it-plus config
## https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus
markdown_it_plus:
html: true
linkify: true
plugins:
- plugin:
name: markdown-it-toc-and-anchor
enable: true
options:
toc: true
tocClassName: 'markdownIt-TOC'
tocFirstLevel: 2
tocLastLevel: 6
tocCallback:
anchorLink: true
anchorLinkSymbol: '🔗'
anchorLinkSpace: true
anchorLinkSymbolClassName:
anchorLinkBefore: true
anchorClassName: 'markdownIt-Anchor'
resetIds: true
- plugin:
name: markdown-it-emoji
enable: false
- plugin:
name: markdown-it-sub
enable: false
- plugin:
name: markdown-it-sup
enable: false
- plugin:
name: markdown-it-deflist
enable: false
- plugin:
name: markdown-it-abbr
enable: false
- plugin:
name: markdown-it-footnote
enable: false
- plugin:
name: markdown-it-mark
enable: false
- plugin:
name: '@iktakahiro/markdown-it-katex'
enable: false
But no toc and anchors are rendered.
There is a problem, this plugin's npm package
and github repository
are different code.
If you use the npm package
, you will meet this problem TypeError: Cannot read property 'type' of undefined
,but it already fix in github repository
, i had submit issue for that #36, the author seems to have forgotten his child.
I try to npm install from github but failed, so i have to clone the code and place here
used here
Ok so how do I make it works ?
It works by default..
@CHENXCHEN As you can see in my two first post that didn't work for me, that's why I opened an issue.
This demo project may help you.
@[toc]
is the required tag to generate the readme.level
for the minimum level of ID creation. There should be a AnchorFirstLevel
and AnchorLastLevel
too. For example I need h2 to h6.This should be achievable with one of the plugin I mentioned before https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus/issues/13#issuecomment-388144623.
I'll consider using hexo-rendered-markdown-it-plus when it will have a proper behavior. Today it makes render my website too ugly.
I don't understand what your means.. You can make this plugin disable if you want, and use other third-party plugins instead.
I didn't managed to make an external plugin work with this project.
You say you are using markdown-it-toc-and-anchor but in dependencies I see only markdown-it-toc that is not the same plugin.
Which one is used ?
And you said in the README that
markdown-it-toc-and-anchor
is enabled by default but no TOC are generated by default so does this mean we need to donpm i markdown-it-toc-and-anchor --save
before ?And how to configure it ? Like that ?