markdown-it-anchor 功能:作为markdown-it的插件使用,帮助markdown-it解析后的HTML,加上锚点(<h/>标签增加id属性),再配合上markdown-it-toc-done-right插件,就可以为markdown自动生成目录(TOC)。 1、安装 # 安装 npm i markdown-it-anchor # 使用constmd=require('markdown-it')().use(require('markdown...
markdown-it-anchor A markdown-it plugin that adds anidattribute to headings and optionally permalinks. English |中文 (v7.0.1) Overview This plugin adds anidattribute to headings, e.g.## Foobecomes<h2 id="foo">Foo</h2>. Optionally it can also includepermalinks, e.g.<h2 id="foo"><...
importMarkdownItfrom"markdown-it";constmarkdown=newMarkdownIt();markdown.render("# Header"); 因此,它应该产生以下结果: <h1>Header</h1> 你也可以把之前提到的插件放进去: constmarkdown=newMarkdownIt().use(MarkdownItAbbr).use(MarkdownItAnchor).use(MarkdownItFootnote).use(MarkdownItHighlightjs...
// markdown通用样式"markdown-it-anchor":"^8.6.7",// 为Markdown标题生成唯一的ID,实现导航"markdown-it-highlightjs":"^4.0.1",// 代码块高亮样式"markdown-it-prism":"^2.3.0",// 代码块高亮样式,和highlightjs功能一致。
markdown-it-anchor 这个插件可以对标题进行锚点抽取,以便阅读文档时能快速定位位置。 这里也可以推测一下,是不是往原本是 heading_open type 的 token 之前插入了一个 token 呢?这个 token 渲染出来就是锚点。 实际上,的确是插入了 token,但不止一个,因为锚点是可点击的,所以实际上是一个 a 链接,也就是 li...
<script>import uslug from'uslug'import MarkdownIt from'markdown-it'import markdownItTocAndAnchor from'markdown-it-toc-and-anchor'data () {return{ mdStr:'相关md字符串', htmlStr:'',//渲染到页面tocArray: [], tocShow: [],//渲染到页面isFirstClickDir:true, ...
markdown-it-anchor Sign UpSign In 1packages found Sort Packages Optimal Popularity Quality Maintenance
varmd=window.markdownit({ html:false, xhtmlOut:true, typographer:true }).use(window.markdownitAnchor,{permalink:true,permalinkBefore:true,permalinkSymbol:'§'}) .use(window.markdownitTocDoneRight); varresult=md.render("# markdown-it rulezz!\n\n${toc}\n## with markdown-it-toc-done-...
.use(window.markdownitSub) .use(window.markdownitSup) .use(window.markdownitFootnote) .use(window.markdownitDeflist) .use(window.markdownitTaskLists) .use(window.markdownitMark) .use(window.markdownItAnchor, {permalink:false,permalinkBefore:false,permalinkSymbol:'#'}) ...
Either for markdown-it-anchor or for markdown-it-toc-done-right. Collaborator nagaozen commented Jul 17, 2019 .use(require('markdown-it-anchor').default) I do not understand where to insert this code. When using markdown-it-anchor, usually you are importing the packages either with ...