zenn-markdown-html 0.1.99 → 0.1.100-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +0 -1
- package/lib/index.js +8 -7
- package/package.json +2 -2
- package/lib/utils/md-line-number.d.ts +0 -2
- package/lib/utils/md-line-number.js +0 -16
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.enablePreview = void 0;
|
|
7
6
|
var markdown_it_1 = __importDefault(require("markdown-it"));
|
|
8
|
-
var
|
|
7
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
9
8
|
// plugis
|
|
10
9
|
var md_container_1 = require("./utils/md-container");
|
|
11
10
|
var md_renderer_fence_1 = require("./utils/md-renderer-fence");
|
|
@@ -53,7 +52,7 @@ md.use(md_br_1.mdBr)
|
|
|
53
52
|
})
|
|
54
53
|
.use(md_katex_1.mdKatex)
|
|
55
54
|
.use(md_linkify_to_card_1.mdLinkifyToCard);
|
|
56
|
-
// custom footnote
|
|
55
|
+
// custom footnote
|
|
57
56
|
md.renderer.rules.footnote_block_open = function () {
|
|
58
57
|
return '<section class="footnotes">\n' +
|
|
59
58
|
'<div class="footnotes-title">脚注</div>\n' +
|
|
@@ -62,9 +61,11 @@ md.renderer.rules.footnote_block_open = function () {
|
|
|
62
61
|
var markdownToHtml = function (text) {
|
|
63
62
|
if (!(text && text.length))
|
|
64
63
|
return '';
|
|
65
|
-
|
|
64
|
+
// docIdは複数のコメントが1ページに指定されたときに脚注のリンク先が重複しないように指定する
|
|
65
|
+
// 1ページの中で重複しなければ問題ないため、ごく短いランダムな文字列とする
|
|
66
|
+
// - https://github.com/zenn-dev/zenn-community/issues/356
|
|
67
|
+
// - https://github.com/markdown-it/markdown-it-footnote/pull/8
|
|
68
|
+
var docId = crypto_1.default.randomBytes(2).toString('hex');
|
|
69
|
+
return md.render(text, { docId: docId });
|
|
66
70
|
};
|
|
67
71
|
exports.default = markdownToHtml;
|
|
68
|
-
exports.enablePreview = function () {
|
|
69
|
-
md_line_number_1.mdLineNumber(md);
|
|
70
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zenn-markdown-html",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.100-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Convert markdown to zenn flavor html.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"markdown-it-task-lists": "^2.1.1",
|
|
46
46
|
"prismjs": "^1.25.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d2877baca5e51e1c12683860a0de43baf57a79f7",
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mdLineNumber = void 0;
|
|
4
|
-
var injectLineNumbers = function (tokens, idx, options, env, slf) {
|
|
5
|
-
var line;
|
|
6
|
-
if (tokens[idx] && tokens[idx].map && tokens[idx].level === 0) {
|
|
7
|
-
line = tokens[idx].map[0];
|
|
8
|
-
tokens[idx].attrJoin('class', 'line');
|
|
9
|
-
tokens[idx].attrSet('data-line', String(line));
|
|
10
|
-
}
|
|
11
|
-
return slf.renderToken(tokens, idx, options);
|
|
12
|
-
};
|
|
13
|
-
exports.mdLineNumber = function (md) {
|
|
14
|
-
md.renderer.rules.paragraph_open = md.renderer.rules.heading_open = injectLineNumbers;
|
|
15
|
-
return md;
|
|
16
|
-
};
|