@vxrn/mdx 2.7.7 → 2.8.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/dist/index.js +120 -24
- package/dist/index.js.map +3 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9492,24 +9492,75 @@ var require_gray_matter = __commonJS({
|
|
|
9492
9492
|
var require_reading_time = __commonJS({
|
|
9493
9493
|
"../../node_modules/reading-time/lib/reading-time.js"(exports2, module2) {
|
|
9494
9494
|
"use strict";
|
|
9495
|
-
function
|
|
9496
|
-
return
|
|
9495
|
+
function codeIsInRanges(number2, arrayOfRanges) {
|
|
9496
|
+
return arrayOfRanges.some(
|
|
9497
|
+
([lowerBound, upperBound]) => lowerBound <= number2 && number2 <= upperBound
|
|
9498
|
+
);
|
|
9497
9499
|
}
|
|
9498
|
-
function
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9500
|
+
function isCJK(c2) {
|
|
9501
|
+
if ("string" !== typeof c2) {
|
|
9502
|
+
return false;
|
|
9503
|
+
}
|
|
9504
|
+
const charCode = c2.charCodeAt(0);
|
|
9505
|
+
return codeIsInRanges(
|
|
9506
|
+
charCode,
|
|
9507
|
+
[
|
|
9508
|
+
// Hiragana (Katakana not included on purpose,
|
|
9509
|
+
// context: https://github.com/ngryman/reading-time/pull/35#issuecomment-853364526)
|
|
9510
|
+
// If you think Katakana should be included and have solid reasons, improvement is welcomed
|
|
9511
|
+
[12352, 12447],
|
|
9512
|
+
// CJK Unified ideographs
|
|
9513
|
+
[19968, 40959],
|
|
9514
|
+
// Hangul
|
|
9515
|
+
[44032, 55203],
|
|
9516
|
+
// CJK extensions
|
|
9517
|
+
[131072, 191456]
|
|
9518
|
+
]
|
|
9519
|
+
);
|
|
9520
|
+
}
|
|
9521
|
+
function isAnsiWordBound(c2) {
|
|
9522
|
+
return " \n\r ".includes(c2);
|
|
9523
|
+
}
|
|
9524
|
+
function isPunctuation(c2) {
|
|
9525
|
+
if ("string" !== typeof c2) {
|
|
9526
|
+
return false;
|
|
9527
|
+
}
|
|
9528
|
+
const charCode = c2.charCodeAt(0);
|
|
9529
|
+
return codeIsInRanges(
|
|
9530
|
+
charCode,
|
|
9531
|
+
[
|
|
9532
|
+
[33, 47],
|
|
9533
|
+
[58, 64],
|
|
9534
|
+
[91, 96],
|
|
9535
|
+
[123, 126],
|
|
9536
|
+
// CJK Symbols and Punctuation
|
|
9537
|
+
[12288, 12351],
|
|
9538
|
+
// Full-width ASCII punctuation variants
|
|
9539
|
+
[65280, 65519]
|
|
9540
|
+
]
|
|
9541
|
+
);
|
|
9542
|
+
}
|
|
9543
|
+
function readingTime3(text4, options2 = {}) {
|
|
9544
|
+
let words = 0, start = 0, end = text4.length - 1;
|
|
9545
|
+
const wordsPerMinute = options2.wordsPerMinute || 200;
|
|
9546
|
+
const isWordBound = options2.wordBound || isAnsiWordBound;
|
|
9547
|
+
while (isWordBound(text4[start])) start++;
|
|
9548
|
+
while (isWordBound(text4[end])) end--;
|
|
9549
|
+
const normalizedText = `${text4}
|
|
9550
|
+
`;
|
|
9551
|
+
for (let i = start; i <= end; i++) {
|
|
9552
|
+
if (isCJK(normalizedText[i]) || !isWordBound(normalizedText[i]) && (isWordBound(normalizedText[i + 1]) || isCJK(normalizedText[i + 1]))) {
|
|
9553
|
+
words++;
|
|
9554
|
+
}
|
|
9555
|
+
if (isCJK(normalizedText[i])) {
|
|
9556
|
+
while (i <= end && (isPunctuation(normalizedText[i + 1]) || isWordBound(normalizedText[i + 1]))) {
|
|
9557
|
+
i++;
|
|
9558
|
+
}
|
|
9559
|
+
}
|
|
9560
|
+
}
|
|
9561
|
+
const minutes = words / wordsPerMinute;
|
|
9562
|
+
const time = Math.round(minutes * 60 * 1e3);
|
|
9563
|
+
const displayed = Math.ceil(minutes.toFixed(2));
|
|
9513
9564
|
return {
|
|
9514
9565
|
text: displayed + " min read",
|
|
9515
9566
|
minutes,
|
|
@@ -9521,10 +9572,47 @@ var require_reading_time = __commonJS({
|
|
|
9521
9572
|
}
|
|
9522
9573
|
});
|
|
9523
9574
|
|
|
9575
|
+
// ../../node_modules/reading-time/lib/stream.js
|
|
9576
|
+
var require_stream5 = __commonJS({
|
|
9577
|
+
"../../node_modules/reading-time/lib/stream.js"(exports2, module2) {
|
|
9578
|
+
"use strict";
|
|
9579
|
+
var readingTime3 = require_reading_time();
|
|
9580
|
+
var Transform = require("stream").Transform;
|
|
9581
|
+
var util = require("util");
|
|
9582
|
+
function ReadingTimeStream(options2) {
|
|
9583
|
+
if (!(this instanceof ReadingTimeStream)) {
|
|
9584
|
+
return new ReadingTimeStream(options2);
|
|
9585
|
+
}
|
|
9586
|
+
Transform.call(this, { objectMode: true });
|
|
9587
|
+
this.options = options2 || {};
|
|
9588
|
+
this.stats = {
|
|
9589
|
+
minutes: 0,
|
|
9590
|
+
time: 0,
|
|
9591
|
+
words: 0
|
|
9592
|
+
};
|
|
9593
|
+
}
|
|
9594
|
+
util.inherits(ReadingTimeStream, Transform);
|
|
9595
|
+
ReadingTimeStream.prototype._transform = function(chunk, encoding, callback) {
|
|
9596
|
+
const stats = readingTime3(chunk.toString(encoding), this.options);
|
|
9597
|
+
this.stats.minutes += stats.minutes;
|
|
9598
|
+
this.stats.time += stats.time;
|
|
9599
|
+
this.stats.words += stats.words;
|
|
9600
|
+
callback();
|
|
9601
|
+
};
|
|
9602
|
+
ReadingTimeStream.prototype._flush = function(callback) {
|
|
9603
|
+
this.stats.text = Math.ceil(this.stats.minutes.toFixed(2)) + " min read";
|
|
9604
|
+
this.push(this.stats);
|
|
9605
|
+
callback();
|
|
9606
|
+
};
|
|
9607
|
+
module2.exports = ReadingTimeStream;
|
|
9608
|
+
}
|
|
9609
|
+
});
|
|
9610
|
+
|
|
9524
9611
|
// ../../node_modules/reading-time/index.js
|
|
9525
9612
|
var require_reading_time2 = __commonJS({
|
|
9526
9613
|
"../../node_modules/reading-time/index.js"(exports2, module2) {
|
|
9527
|
-
module2.exports = require_reading_time();
|
|
9614
|
+
module2.exports.default = module2.exports = require_reading_time();
|
|
9615
|
+
module2.exports.readingTimeStream = require_stream5();
|
|
9528
9616
|
}
|
|
9529
9617
|
});
|
|
9530
9618
|
|
|
@@ -34516,10 +34604,16 @@ function quotesDefault(state, node2, index3, parent) {
|
|
|
34516
34604
|
}
|
|
34517
34605
|
|
|
34518
34606
|
// ../../node_modules/remark-smartypants/dist/plugin.js
|
|
34519
|
-
var VISITED_NODES = /* @__PURE__ */ new Set([
|
|
34607
|
+
var VISITED_NODES = /* @__PURE__ */ new Set([
|
|
34608
|
+
"text",
|
|
34609
|
+
"inlineCode",
|
|
34610
|
+
"paragraph",
|
|
34611
|
+
"heading",
|
|
34612
|
+
"tableCell"
|
|
34613
|
+
]);
|
|
34520
34614
|
var IGNORED_HTML_ELEMENTS = /* @__PURE__ */ new Set(["style", "script"]);
|
|
34521
34615
|
var check = (node2, index3, parent) => {
|
|
34522
|
-
return parent && (parent.type !== "mdxJsxTextElement" || "name" in parent && typeof parent.name === "string" && !IGNORED_HTML_ELEMENTS.has(parent.name)) && VISITED_NODES.has(node2.type) && (isLiteral(node2) ||
|
|
34616
|
+
return parent && (parent.type !== "mdxJsxTextElement" || "name" in parent && typeof parent.name === "string" && !IGNORED_HTML_ELEMENTS.has(parent.name)) && VISITED_NODES.has(node2.type) && (isLiteral(node2) || isBlock(node2));
|
|
34523
34617
|
};
|
|
34524
34618
|
var remarkSmartypants = (options2) => {
|
|
34525
34619
|
const processor = retext().use(retextSmartypants, {
|
|
@@ -34544,7 +34638,7 @@ var remarkSmartypants = (options2) => {
|
|
|
34544
34638
|
visit6(tree, check, (node2) => {
|
|
34545
34639
|
if (isLiteral(node2)) {
|
|
34546
34640
|
allText += node2.type === "text" ? node2.value : "A".repeat(node2.value.length);
|
|
34547
|
-
} else if (
|
|
34641
|
+
} else if (isBlock(node2)) {
|
|
34548
34642
|
allText += " ";
|
|
34549
34643
|
}
|
|
34550
34644
|
nodes.push(node2);
|
|
@@ -34558,7 +34652,7 @@ var remarkSmartypants = (options2) => {
|
|
|
34558
34652
|
node2.value = processor2.processSync(processedText).toString();
|
|
34559
34653
|
}
|
|
34560
34654
|
startIndex = endIndex;
|
|
34561
|
-
} else if (
|
|
34655
|
+
} else if (isBlock(node2)) {
|
|
34562
34656
|
startIndex += 1;
|
|
34563
34657
|
}
|
|
34564
34658
|
}
|
|
@@ -34567,8 +34661,9 @@ var remarkSmartypants = (options2) => {
|
|
|
34567
34661
|
function isLiteral(node2) {
|
|
34568
34662
|
return "value" in node2 && typeof node2.value === "string";
|
|
34569
34663
|
}
|
|
34570
|
-
|
|
34571
|
-
|
|
34664
|
+
var BLOCK_NODES = /* @__PURE__ */ new Set(["paragraph", "heading", "tableCell"]);
|
|
34665
|
+
function isBlock(node2) {
|
|
34666
|
+
return BLOCK_NODES.has(node2.type);
|
|
34572
34667
|
}
|
|
34573
34668
|
var plugin_default = remarkSmartypants;
|
|
34574
34669
|
|
|
@@ -34782,6 +34877,7 @@ strip-bom-string/index.js:
|
|
|
34782
34877
|
*)
|
|
34783
34878
|
|
|
34784
34879
|
reading-time/lib/reading-time.js:
|
|
34880
|
+
reading-time/lib/stream.js:
|
|
34785
34881
|
(*!
|
|
34786
34882
|
* reading-time
|
|
34787
34883
|
* Copyright (c) Nicolas Gryman <ngryman@gmail.com>
|