New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kaciras-blog/markdown

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kaciras-blog/markdown - npm Package Compare versions

Comparing version 3.2.2 to 3.3.0

lib/diagnostics.d.ts

2

lib/activate.js

@@ -1,2 +0,2 @@

import { a as f } from "./fence-6ZKU-3dl.js";
import { a as f } from "./fence-jxMdD6OG.js";
import { silencePromise as u, identity as d } from "@kaciras/utilities/browser";

@@ -3,0 +3,0 @@ function g(n, o) {

@@ -0,1 +1,3 @@

import Token from "markdown-it/lib/token.mjs";
import Renderer from "markdown-it/lib/renderer.mjs";
import MarkdownIt from "markdown-it";

@@ -29,7 +31,8 @@ export interface GenericDirective {

*
* @param href 圆括号里的内容,已过滤危险链接。
* @param label 方括号里的内容。
* @param this MarkdownIt 的渲染器。
* @param token 要渲染的 Token。
* @param md MarkdownIt 对象。
* @param env 用户自定义的对象。
*/
[type: string]: (href: string, label: string, md: MarkdownIt) => string;
[type: string]: (this: Renderer, token: Token, md: MarkdownIt, env: any) => string;
}

@@ -36,0 +39,0 @@ /**

@@ -7,5 +7,5 @@ /// <reference types="markdown-it-toc-done-right" />

export * from "./activate.js";
export * from "./diagnostics.js";
export { default as MarkdownIt } from "markdown-it";
export { default as toc } from "markdown-it-toc-done-right";
export { default as collect } from "./collect.js";
export { default as directive } from "./directive.js";

@@ -12,0 +12,0 @@ export { default as collapsible } from "./collapsible.js";

@@ -1,12 +0,12 @@

import { unescapeMd as p, escapeHtml as v } from "markdown-it/lib/common/utils.mjs";
import y from "markdown-it-toc-done-right";
import { default as qe } from "markdown-it-toc-done-right";
import m from "markdown-it-anchor";
import L from "markdown-it-footnote";
import { f as w } from "./fence-6ZKU-3dl.js";
import { unescapeMd as m, escapeHtml as y } from "markdown-it/lib/common/utils.mjs";
import L from "markdown-it-toc-done-right";
import { default as Oe } from "markdown-it-toc-done-right";
import d from "markdown-it-anchor";
import w from "markdown-it-footnote";
import { f as $ } from "./fence-jxMdD6OG.js";
import a from "highlight.js/lib/core";
import $ from "highlight.js/lib/languages/c";
import x from "highlight.js/lib/languages/cpp";
import M from "highlight.js/lib/languages/xml";
import _ from "highlight.js/lib/languages/csharp";
import x from "highlight.js/lib/languages/c";
import _ from "highlight.js/lib/languages/cpp";
import A from "highlight.js/lib/languages/xml";
import M from "highlight.js/lib/languages/csharp";
import j from "highlight.js/lib/languages/css";

@@ -16,23 +16,23 @@ import C from "highlight.js/lib/languages/dockerfile";

import B from "highlight.js/lib/languages/http";
import A from "highlight.js/lib/languages/ini";
import T from "highlight.js/lib/languages/java";
import z from "highlight.js/lib/languages/javascript";
import E from "highlight.js/lib/languages/json";
import T from "highlight.js/lib/languages/ini";
import z from "highlight.js/lib/languages/java";
import E from "highlight.js/lib/languages/javascript";
import I from "highlight.js/lib/languages/json";
import P from "highlight.js/lib/languages/kotlin";
import F from "highlight.js/lib/languages/less";
import G from "highlight.js/lib/languages/lua";
import H from "highlight.js/lib/languages/protobuf";
import I from "highlight.js/lib/languages/python";
import D from "highlight.js/lib/languages/rust";
import N from "highlight.js/lib/languages/scss";
import R from "highlight.js/lib/languages/shell";
import q from "highlight.js/lib/languages/sql";
import H from "highlight.js/lib/languages/lua";
import D from "highlight.js/lib/languages/protobuf";
import G from "highlight.js/lib/languages/python";
import N from "highlight.js/lib/languages/rust";
import R from "highlight.js/lib/languages/scss";
import q from "highlight.js/lib/languages/shell";
import J from "highlight.js/lib/languages/sql";
import O from "highlight.js/lib/languages/yaml";
import U from "highlight.js/lib/languages/typescript";
import { default as Ue } from "markdown-it";
function W(e, r, s, t) {
const n = e.tShift[r] + e.bMarks[r], i = e.src.slice(n, e.eMarks[r]);
import { default as We } from "markdown-it";
function W(e, r, n, t) {
const s = e.tShift[r] + e.bMarks[r], i = e.src.slice(s, e.eMarks[r]);
let o;
try {
o = J(i);
o = V(i);
} catch {

@@ -42,12 +42,12 @@ return !1;

if (!t) {
const { type: c, label: l, href: u, attrs: b } = o, f = e.push("directive", c, 0);
f.attrs = [["href", u]], f.meta = b, f.content = l, f.map = [r, e.line];
const { type: c, label: l, href: u, attrs: v } = o, p = e.push("directive", c, 0);
p.meta = v, p.content = l, p.map = [r, r + 1], p.attrs = [["src", K(e.md, u)]];
}
return e.line = r + 1, !0;
}
function J(e) {
function V(e) {
const r = /^@([a-z][a-z0-9\-_]*)/i.exec(e);
if (!r)
throw new Error("Not a directive syntax.");
const [{ length: s }, t] = r, n = d(e, s, 91, 93), i = d(e, n + 1, 40, 41), o = p(e.slice(s + 1, n)), c = p(e.slice(n + 2, i)), l = i + 1;
const [{ length: n }, t] = r, s = h(e, n, 91, 93), i = h(e, s + 1, 40, 41), o = m(e.slice(n + 1, s)), c = m(e.slice(s + 2, i)), l = i + 1;
let u = {};

@@ -60,8 +60,8 @@ if (e.charCodeAt(l) === 123)

}
function d(e, r, s, t) {
if (e.charCodeAt(r) !== s) {
const i = String.fromCharCode(s), o = e.charAt(r);
function h(e, r, n, t) {
if (e.charCodeAt(r) !== n) {
const i = String.fromCharCode(n), o = e.charAt(r);
throw new Error(`Expect ${i}, but found ${o}`);
}
let n = 1;
let s = 1;
for (; ++r < e.length; ) {

@@ -72,46 +72,46 @@ switch (e.charCodeAt(r)) {

break;
case s:
n++;
case n:
s++;
break;
case t:
n--;
s--;
break;
}
if (n === 0)
if (s === 0)
return r;
}
throw new Error(`Bracket count does not match, level=${n}`);
throw new Error(`Bracket count does not match, level=${s}`);
}
function V(e, r) {
function K(e, r) {
return r = e.normalizeLink(r), e.validateLink(r) ? r : "";
}
const K = {
const Q = {
audio(e) {
return `<audio src="${e}" controls></audio>`;
return `<audio${this.renderAttrs(e)} controls></audio>`;
},
video(e, r, s) {
let t = `src="${e}"`;
return r = s.normalizeLink(r), r && s.validateLink(r) && (t += ` poster="${r}"`), `<video ${t} controls></video>`;
video(e, r) {
const n = r.normalizeLink(e.content);
return n && r.validateLink(n) && e.attrs.push(["poster", n]), `<video${this.renderAttrs(e)} controls></video>`;
},
// 仍然加上 controls 避免无法播放
gif(e) {
return `<video src="${e}" loop muted controls></video>`;
return `<video${this.renderAttrs(e)} loop muted controls></video>`;
}
};
function h(e, r = K) {
e.renderer.rules.directive = (s, t) => {
const n = s[t], { tag: i, content: o } = n, c = n.attrGet("href"), l = r[i];
return l ? l(V(e, c), o, e) : `[Unknown directive: ${i}]`;
function k(e, r = Q) {
e.renderer.rules.directive = (n, t, s, i, o) => {
const c = n[t], l = r[c.tag];
return l ? l.call(o, c, e, i) : `[Unknown directive: ${c.tag}]`;
}, e.block.ruler.before("html_block", "directive", W);
}
var Q = /* @__PURE__ */ ((e) => (e[e.None = 0] = "None", e[e.Italic = 1] = "Italic", e[e.Bold = 2] = "Bold", e[e.Code = 4] = "Code", e[e.StrikeThrough = 8] = "StrikeThrough", e))(Q || {});
function He(e) {
let r = 0, s = 0, t = e.length - 1, n = 0, i = e.charCodeAt(0);
var X = /* @__PURE__ */ ((e) => (e[e.None = 0] = "None", e[e.Italic = 1] = "Italic", e[e.Bold = 2] = "Bold", e[e.Code = 4] = "Code", e[e.StrikeThrough = 8] = "StrikeThrough", e))(X || {});
function De(e) {
let r = 0, n = 0, t = e.length - 1, s = 0, i = e.charCodeAt(0);
if (t < 1)
return [0, 0];
function o() {
return n === 0 ? 0 : i === 126 && n === 2 ? 8 : i === 96 ? 4 : i !== 42 && i !== 95 ? 0 : n === 1 ? 1 : n === 2 ? 2 : 3;
return s === 0 ? 0 : i === 126 && s === 2 ? 8 : i === 96 ? 4 : i !== 42 && i !== 95 ? 0 : s === 1 ? 1 : s === 2 ? 2 : 3;
}
for (; s < t; s++, t--, n++) {
const l = e.charCodeAt(s);
for (; n < t; n++, t--, s++) {
const l = e.charCodeAt(n);
if (l !== e.charCodeAt(t))

@@ -123,9 +123,9 @@ break;

break;
n = 0, i = l, r |= u;
s = 0, i = l, r |= u;
}
}
const c = o();
return [r | c, c === 0 ? s - n : s];
return [r | c, c === 0 ? n - s : n];
}
function X(e) {
function Y(e) {
return {

@@ -182,6 +182,6 @@ subLanguage: "xml",

}
a.registerLanguage("c", $);
a.registerLanguage("cpp", x);
a.registerLanguage("xml", M);
a.registerLanguage("cs", _);
a.registerLanguage("c", x);
a.registerLanguage("cpp", _);
a.registerLanguage("xml", A);
a.registerLanguage("cs", M);
a.registerLanguage("css", j);

@@ -191,33 +191,33 @@ a.registerLanguage("dockerfile", C);

a.registerLanguage("http", B);
a.registerLanguage("ini", A);
a.registerLanguage("java", T);
a.registerLanguage("javascript", z);
a.registerLanguage("json", E);
a.registerLanguage("ini", T);
a.registerLanguage("java", z);
a.registerLanguage("javascript", E);
a.registerLanguage("json", I);
a.registerLanguage("kotlin", P);
a.registerLanguage("less", F);
a.registerLanguage("lua", G);
a.registerLanguage("protobuf", H);
a.registerLanguage("python", I);
a.registerLanguage("rust", D);
a.registerLanguage("scss", N);
a.registerLanguage("shell", R);
a.registerLanguage("sql", q);
a.registerLanguage("lua", H);
a.registerLanguage("protobuf", D);
a.registerLanguage("python", G);
a.registerLanguage("rust", N);
a.registerLanguage("scss", R);
a.registerLanguage("shell", q);
a.registerLanguage("sql", J);
a.registerLanguage("yaml", O);
a.registerLanguage("typescript", U);
a.registerLanguage("vue", X);
function Y(e, r, s) {
a.registerLanguage("vue", Y);
function Z(e, r, n) {
if (!a.getLanguage(r))
return v(e);
if (s !== "diff")
return y(e);
if (n !== "diff")
return a.highlight(e, { language: r }).value;
let t = e.split(`
`);
const n = /* @__PURE__ */ new Map();
const s = /* @__PURE__ */ new Map();
for (let o = 0; o < t.length; o++) {
switch (t[o].charCodeAt(0)) {
case 43:
n.set(o, !0);
s.set(o, !0);
break;
case 45:
n.set(o, !1);
s.set(o, !1);
break;

@@ -234,3 +234,3 @@ default:

for (let o = 0; o < t.length; o++) {
switch (n.has(o - 1) && i.push("</span>"), n.get(o)) {
switch (s.has(o - 1) && i.push("</span>"), s.get(o)) {
case !0:

@@ -248,36 +248,47 @@ i.push("<span class='hljs-insert'>");

}
function k(e) {
const r = new URLSearchParams(e.split("?")[1]), s = parseFloat(r.get("vw")), t = parseFloat(r.get("vh"));
return s && t ? `style='--width:${s}px;--aspect:${s}/${t}'` : "";
function b(e) {
const r = new URLSearchParams(e.split("?")[1]), n = parseFloat(r.get("vw")), t = parseFloat(r.get("vh"));
return n && t ? `style='--width:${n}px;--aspect:${n}/${t}'` : "";
}
function Z(e, r) {
const s = e[r], t = s.attrGet("src") ?? "", n = this.utils.escapeHtml(s.content);
return `<span class="md-center" ${k(t)}><a class="md-inspect" href="${t}" target="_blank" rel="noopener,nofollow"><img data-src="${t}" alt="${n}" class="md-img" crossorigin></a>${n ? `<span class="md-alt">${n}</span>` : ""}</span>`;
function f(e, r) {
const n = r.attrIndex("src"), t = r.attrs[n][1];
return r.attrs.splice(n, 1), r.attrJoin("class", "md-center"), [t, e.renderAttrs(r).trimStart()];
}
const ee = {
function ee(e, r, n, t, s) {
const i = e[r];
i.attrs.splice(i.attrIndex("alt"), 1);
const [o, c] = f(s, i), l = this.utils.escapeHtml(i.content);
return `<span ${c}><a ${b(o)} class="md-inspect" href="${o}" target="_blank" rel="noopener,nofollow"><img data-src="${o}" alt="${l}" class="md-img" crossorigin></a>${l ? `<span class="md-alt">${l}</span>` : ""}</span>`;
}
const re = {
// 大部分浏览器只允许无声视频自动播放,不过 GIF 视频本来就是无声的。
gif(e, r, s) {
return r = s.utils.escapeHtml(r), `<p class="md-center" ${k(e)}><video class="gif" crossorigin loop muted data-src="${e}"></video>${r ? `<span class="md-alt">${r}</span>` : ""}</p>`;
gif(e, r) {
const n = r.utils.escapeHtml(e.content), [t, s] = f(this, e);
return `<p ${s}><video ${b(t)} class="gif" crossorigin loop muted data-src="${t}"></video>${n ? `<span class="md-alt">${n}</span>` : ""}</p>`;
},
video(e, r, s) {
return r = s.normalizeLink(r), s.validateLink(r) || (r = ""), `<p class="md-center"><video class="md-video" controls crossorigin poster="${r}" data-src="${e}"></video></p>`;
video(e, r) {
let n = r.normalizeLink(e.content);
r.validateLink(n) || (n = "");
const [t, s] = f(this, e);
return `<p ${s}><video class="md-video" controls crossorigin poster="${n}" data-src="${t}"></video></p>`;
},
audio(e, r, s) {
return r = s.utils.escapeHtml(r), `<p class="md-center"><audio controls data-src="${e}" crossorigin></audio>${r ? `<span class="md-alt">${r}</span>` : ""}</p>`;
audio(e, r) {
const n = r.utils.escapeHtml(e.content), [t, s] = f(this, e);
return `<p ${s}><audio controls data-src="${t}" crossorigin></audio>${n ? `<span class="md-alt">${n}</span>` : ""}</p>`;
}
};
function re(e) {
e.use(h, ee), e.renderer.rules.image = Z.bind(e);
function te(e) {
e.use(k, re), e.renderer.rules.image = ee.bind(e);
}
function g(e, r, s) {
const { src: t, bMarks: n, tShift: i, eMarks: o } = e, c = n[r] + i[r], l = o[r];
return c + s.length === l && t.startsWith(s, c);
function g(e, r, n) {
const { src: t, bMarks: s, tShift: i, eMarks: o } = e, c = s[r] + i[r], l = o[r];
return c + n.length === l && t.startsWith(n, c);
}
function te(e, r, s) {
function ne(e, r, n) {
if (!g(e, r, "<details>"))
return !1;
let t = r + 1, n = 1;
for (; t < s && n > 0; t++)
g(e, t, "<details>") ? n += 1 : g(e, t, "</details>") && (n -= 1);
if (n !== 0)
let t = r + 1, s = 1;
for (; t < n && s > 0; t++)
g(e, t, "<details>") ? s += 1 : g(e, t, "</details>") && (s -= 1);
if (s !== 0)
return !1;

@@ -287,28 +298,28 @@ const i = e.parentType, o = e.lineMax;

let c = e.push("collapsible_open", "details", 1);
return c.block = !0, c.markup = "<details>", c.map = [r, r + 1], e.md.block.tokenize(e, r + 1, t - 1), c = e.push("collapsible_close", "details", -1), c.block = !0, c.markup = "</details>", e.parentType = i, e.lineMax = o, e.line = t, !0;
return c.block = !0, c.markup = "<details>", c.map = [r, t], e.md.block.tokenize(e, r + 1, t - 1), c = e.push("collapsible_close", "details", -1), c.block = !0, c.markup = "</details>", e.parentType = i, e.lineMax = o, e.line = t, !0;
}
function ne(e, r, s) {
const { src: t, bMarks: n, eMarks: i } = e;
function se(e, r, n) {
const { src: t, bMarks: s, eMarks: i } = e;
if (!g(e, r, "<summary>") || e.tokens.at(-1)?.type !== "collapsible_open")
return !1;
let o = r += 1;
for (; o < s && !g(e, o, "</summary>"); o++)
for (; o < n && !g(e, o, "</summary>"); o++)
;
e.push("summary_open", "summary", 1);
const c = e.push("inline", "", 0);
return c.children = [], c.content = t.slice(n[r], i[o - 1]), e.push("summary_close", "summary", -1), e.line = o + 1, !0;
return c.children = [], c.content = t.slice(s[r], i[o - 1]), e.push("summary_close", "summary", -1), e.line = o + 1, !0;
}
function se(e) {
e.block.ruler.before("fence", "collapsible", te), e.block.ruler.before("fence", "summary", ne);
function oe(e) {
e.block.ruler.before("fence", "collapsible", ne), e.block.ruler.before("fence", "summary", se);
}
function oe(e) {
const { renderer: r } = e, s = r.renderToken;
r.renderToken = function(t, n, i) {
const o = t[n];
return o.type === "link_open" && o.attrPush(["rel", "ugc,nofollow"]), s.call(this, t, n, i);
function ie(e) {
const { renderer: r } = e, n = r.renderToken;
r.renderToken = function(t, s, i) {
const o = t[s];
return o.type === "link_open" && o.attrPush(["rel", "ugc,nofollow"]), n.call(this, t, s, i);
};
}
function ie(e) {
e.use(m, {
permalink: m.permalink.linkInsideHeader({
function ae(e) {
e.use(d, {
permalink: d.permalink.linkInsideHeader({
placement: "after",

@@ -320,52 +331,62 @@ class: "anchor-link"

}
function ae(e) {
e.use(L);
function ce(e) {
e.use(w);
const { rules: r } = e.renderer;
r.footnote_block_open = () => "<h2 class='footnotes'></h2><ol class='footnotes-list'>", r.footnote_block_close = () => "</ol>";
}
function ce(e) {
const { rules: r } = e.renderer, s = r.code_inline;
r.code_inline = function(t, n, ...i) {
return t[n].attrPush(["class", "inline-code"]), s.call(this, t, n, ...i);
function le(e) {
const { rules: r } = e.renderer, n = r.code_inline;
r.code_inline = function(t, s, ...i) {
return t[s].attrPush(["class", "inline-code"]), n.call(this, t, s, ...i);
};
}
function Ie(e, r = {}) {
return r.plain ? e.use(h) : (r.guest || e.use(ie), e.options.highlight ??= Y, e.use(w), e.use(re), e.use(ce)), r.guest ? e.use(oe) : e.use(y), e.use(ae).use(se);
function Ge(e, r = {}) {
return r.plain ? e.use(k) : (r.guest || e.use(ae), e.options.highlight ??= Z, e.use($), e.use(te), e.use(le)), r.guest ? e.use(ie) : e.use(L), e.use(ce).use(oe);
}
function De(e, r) {
function s(t) {
for (const n of t)
switch (n.type) {
function Ne(e) {
e.core.ruler.push("source-line", (r) => {
for (const n of r.tokens)
if (n.map && n.type !== "inline") {
const [t, s] = n.map;
n.attrSet("data-line", `${t},${s}`);
}
});
}
function Re(e, r) {
function n(t) {
for (const s of t)
switch (s.type) {
case "inline":
s(n.children);
n(s.children);
break;
case "link_open":
case "directive":
r(n.attrGet("href"));
r(s.attrGet("href"));
break;
case "image":
r(n.attrGet("src"));
case "directive":
r(s.attrGet("src"));
break;
}
}
e.core.ruler.push("collect-links", (t) => s(t.tokens));
e.core.ruler.push("collect-links", (t) => n(t.tokens));
}
export {
Q as Emphasis,
Ue as MarkdownIt,
ie as anchor,
ce as classify,
se as collapsible,
De as collect,
K as defaultDirectiveMap,
h as directive,
w as fence,
ae as footnote,
He as getEmphasis,
Y as highlight,
Ie as kfmPreset,
re as media,
J as parseGenericDirective,
qe as toc,
oe as ugc
X as Emphasis,
We as MarkdownIt,
ae as anchor,
le as classify,
oe as collapsible,
Re as collect,
Q as defaultDirectiveMap,
k as directive,
$ as fence,
ce as footnote,
De as getEmphasis,
Z as highlight,
Ge as kfmPreset,
te as media,
V as parseGenericDirective,
Ne as sourceLine,
Oe as toc,
ie as ugc
};

@@ -45,4 +45,4 @@ import MarkdownIt from "markdown-it";

/**
* 一次性添加其他所有 KFM 插件的插件,用于一些常见情况。
* 一次性添加其他所有 KFM 插件的插件(不包括 diagnostics.ts 里的),用于一些常见情况。
*/
export declare function kfmPreset(md: MarkdownIt, options?: PresetOptions): MarkdownIt;

@@ -1,1 +0,1 @@

export default function (code: string, language: string, attrs?: string): string;
export default function (code: string, language: string, attrs?: string): any;

@@ -1,2 +0,2 @@

import type MarkdownIt from "markdown-it";
import MarkdownIt from "markdown-it";
/**

@@ -3,0 +3,0 @@ * 自定义媒体元素的前端版,覆盖 Media 插件和默认的图片渲染器,

{
"name": "@kaciras-blog/markdown",
"version": "3.2.2",
"version": "3.3.0",
"license": "MIT",

@@ -21,7 +21,7 @@ "description": "Kaciras Flavored Markdown",

"dependencies": {
"@kaciras/utilities": "^0.12.1",
"@kaciras/utilities": "^0.13.0",
"bootstrap-icons": "^1.11.3",
"highlight.js": "^11.9.0",
"markdown-it": "^14.0.0",
"markdown-it-anchor": "^8.6.7",
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.0.1",
"markdown-it-footnote": "^4.0.0",

@@ -32,10 +32,10 @@ "markdown-it-toc-done-right": "^4.2.0"

"@types/html-minifier-terser": "^7.0.2",
"@types/markdown-it": "^13.0.7",
"@vitest/coverage-v8": "^1.2.2",
"@types/markdown-it": "^14.1.1",
"@vitest/coverage-v8": "^1.6.0",
"html-minifier-terser": "^7.2.0",
"magic-string": "^0.30.6",
"magic-string": "^0.30.10",
"postcss-nested": "^6.0.1",
"postcss-simple-vars": "^7.0.1",
"vite": "^5.0.12",
"vitest": "^1.2.2"
"vite": "^5.2.11",
"vitest": "^1.6.0"
},

@@ -42,0 +42,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc