hexo-renderer-markdown-it
Advanced tools
Comparing version
@@ -17,2 +17,4 @@ 'use strict'; | ||
var titleStore = {}; | ||
var anchor = function (md, opts) { | ||
@@ -36,6 +38,11 @@ opts = assign({}, anchor.defaults, opts); | ||
var slug = sluggo(title); | ||
var label = tokens[idx + 1]; | ||
slug = slug + '-' + (label.map[0] + 1) | ||
.toString(); | ||
if (titleStore.hasOwnProperty(slug)) { | ||
titleStore[slug] = titleStore[slug] + 1; | ||
slug = slug + '-' + opts.collisionSuffix + titleStore[slug].toString(); | ||
} else { | ||
titleStore[slug] = 1; | ||
} | ||
(_tokens$idx = tokens[idx], !_tokens$idx.attrs && (_tokens$idx.attrs = []), _tokens$idx.attrs) | ||
@@ -57,2 +64,3 @@ .push(['id', slug]); | ||
level: 1, | ||
collisionSuffix: 'v', | ||
permalink: false, | ||
@@ -59,0 +67,0 @@ renderPermalink: renderPermalink, |
{ | ||
"name": "hexo-renderer-markdown-it", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Markdown-it is a Markdown parser, done right. A faster and CommonMark compliant alternative for Hexo.", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -30,12 +30,14 @@ # hexo-renderer-markdown-it | ||
## Changelog | ||
### 3.3.0 | ||
- Modified the ID collisions feature (reading the number of times the header repeats itself) | ||
- Added option `collisionSuffix` which allows a suffix to be passed after the heading ID slug. | ||
### 3.2.1 | ||
- Bugfixes | ||
### 3.2.0 | ||
- Integrated `markdown-it-anchors` and changed the slugify function | ||
- Implemented a way to prevent ID collisions in headings (using the heading line). | ||
- Remade the tests. | ||
- Implemented a way to prevent ID collisions in headings (using the heading line) | ||
- Remade the tests | ||
### 3.1.0 | ||
- Added support for `<ins>` tag | ||
- Refactored the renderer | ||
- Refactored the tests | ||
[CommonMark]: http://commonmark.org/ | ||
@@ -42,0 +44,0 @@ [Markdown]: http://daringfireball.net/projects/markdown/ |
8267
3.8%80
6.67%47
4.44%