@kaciras-blog/markdown
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -1,2 +0,2 @@ | ||
import { a as f } from "./fence-78fb79d9.js"; | ||
import { a as f } from "./fence-Kc-htwcQ.js"; | ||
import { silencePromise as u, identity as d } from "@kaciras/utilities/browser"; | ||
@@ -3,0 +3,0 @@ function g(n, o) { |
import MarkdownIt from "markdown-it"; | ||
export default function (markdownIt: MarkdownIt): void; | ||
export default function (md: MarkdownIt): void; |
@@ -5,5 +5,5 @@ import MarkdownIt from "markdown-it"; | ||
* | ||
* @param markdownIt 要安装到的 MarkdownIt 对象。 | ||
* @param md 要安装到的 MarkdownIt 对象。 | ||
* @param handler 找到的链接将传递给这个函数。 | ||
*/ | ||
export default function (markdownIt: MarkdownIt, handler: (url: string) => void): void; | ||
export default function (md: MarkdownIt, handler: (url: string) => void): void; |
@@ -32,2 +32,2 @@ import MarkdownIt from "markdown-it"; | ||
export declare const defaultDirectiveMap: Readonly<DirectiveMap>; | ||
export default function (markdownIt: MarkdownIt, map?: Readonly<DirectiveMap>): void; | ||
export default function (md: MarkdownIt, map?: Readonly<DirectiveMap>): void; |
@@ -11,4 +11,6 @@ export declare enum Emphasis { | ||
* | ||
* @return [强调类型, 强调字符串的长度(一侧)] 二元组。 | ||
* @return [强调类型, 强调字符串的长度] 二元组。 | ||
* @example | ||
* getEmphasis("`**text**`") // [Emphasis.Bold | Emphasis.Code, 3] | ||
*/ | ||
export declare function getEmphasis(text: string): [Emphasis, number]; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="markdown-it-toc-done-right" /> | ||
import "./web/markdown.css"; | ||
@@ -2,0 +3,0 @@ export * from "./directive.js"; |
110
lib/index.js
@@ -1,10 +0,10 @@ | ||
import v, { unescapeMd as p } from "markdown-it/lib/common/utils.js"; | ||
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 Oe } from "markdown-it-toc-done-right"; | ||
import { default as De } from "markdown-it-toc-done-right"; | ||
import m from "markdown-it-anchor"; | ||
import L from "markdown-it-footnote"; | ||
import { f as $ } from "./fence-78fb79d9.js"; | ||
import { f as w } from "./fence-Kc-htwcQ.js"; | ||
import a from "highlight.js/lib/core"; | ||
import x from "highlight.js/lib/languages/c"; | ||
import w from "highlight.js/lib/languages/cpp"; | ||
import $ from "highlight.js/lib/languages/c"; | ||
import x from "highlight.js/lib/languages/cpp"; | ||
import M from "highlight.js/lib/languages/xml"; | ||
@@ -23,16 +23,16 @@ import _ from "highlight.js/lib/languages/csharp"; | ||
import H from "highlight.js/lib/languages/lua"; | ||
import G from "highlight.js/lib/languages/protobuf"; | ||
import N from "highlight.js/lib/languages/python"; | ||
import R from "highlight.js/lib/languages/rust"; | ||
import q from "highlight.js/lib/languages/scss"; | ||
import D from "highlight.js/lib/languages/shell"; | ||
import O from "highlight.js/lib/languages/sql"; | ||
import U from "highlight.js/lib/languages/yaml"; | ||
import W from "highlight.js/lib/languages/typescript"; | ||
import { default as We } from "markdown-it"; | ||
function J(e, r, s, t) { | ||
import I 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 D 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]); | ||
let o; | ||
try { | ||
o = V(i); | ||
o = J(i); | ||
} catch { | ||
@@ -47,3 +47,3 @@ return !1; | ||
} | ||
function V(e) { | ||
function J(e) { | ||
const r = /^@([a-z][a-z0-9\-_]*)/i.exec(e); | ||
@@ -83,6 +83,6 @@ if (!r) | ||
} | ||
function K(e, r) { | ||
function V(e, r) { | ||
return r = e.normalizeLink(r), e.validateLink(r) ? r : ""; | ||
} | ||
const Q = { | ||
const K = { | ||
audio(e) { | ||
@@ -100,10 +100,10 @@ return `<audio src="${e}" controls></audio>`; | ||
}; | ||
function h(e, r = Q) { | ||
function h(e, r = K) { | ||
e.renderer.rules.directive = (s, t) => { | ||
const n = s[t], { tag: i, content: o } = n, l = n.attrGet("href"), c = r[i]; | ||
return c ? c(K(e, l), o, e) : `[Unknown directive: ${i}]`; | ||
}, e.block.ruler.before("html_block", "directive", J); | ||
return c ? c(V(e, l), o, e) : `[Unknown directive: ${i}]`; | ||
}, e.block.ruler.before("html_block", "directive", W); | ||
} | ||
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 Ge(e) { | ||
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 Ie(e) { | ||
let r = 0, s = 0, t = e.length - 1, n = 0, i = e.charCodeAt(0); | ||
@@ -129,3 +129,3 @@ if (t < 1) | ||
} | ||
function Y(e) { | ||
function X(e) { | ||
return { | ||
@@ -182,4 +182,4 @@ subLanguage: "xml", | ||
} | ||
a.registerLanguage("c", x); | ||
a.registerLanguage("cpp", w); | ||
a.registerLanguage("c", $); | ||
a.registerLanguage("cpp", x); | ||
a.registerLanguage("xml", M); | ||
@@ -198,14 +198,14 @@ a.registerLanguage("cs", _); | ||
a.registerLanguage("lua", H); | ||
a.registerLanguage("protobuf", G); | ||
a.registerLanguage("python", N); | ||
a.registerLanguage("rust", R); | ||
a.registerLanguage("scss", q); | ||
a.registerLanguage("shell", D); | ||
a.registerLanguage("sql", O); | ||
a.registerLanguage("yaml", U); | ||
a.registerLanguage("typescript", W); | ||
a.registerLanguage("vue", Y); | ||
function Z(e, r, s) { | ||
a.registerLanguage("protobuf", I); | ||
a.registerLanguage("python", G); | ||
a.registerLanguage("rust", N); | ||
a.registerLanguage("scss", R); | ||
a.registerLanguage("shell", q); | ||
a.registerLanguage("sql", D); | ||
a.registerLanguage("yaml", O); | ||
a.registerLanguage("typescript", U); | ||
a.registerLanguage("vue", X); | ||
function Y(e, r, s) { | ||
if (!a.getLanguage(r)) | ||
return v.escapeHtml(e); | ||
return v(e); | ||
if (s !== "diff") | ||
@@ -251,3 +251,3 @@ return a.highlight(e, { language: r }).value; | ||
} | ||
function I(e, r) { | ||
function Z(e, r) { | ||
const s = e[r], t = s.attrGet("src") ?? "", n = this.utils.escapeHtml(s.content); | ||
@@ -269,3 +269,3 @@ return `<span class="center-wrapper"><a ${k(t)} 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 re(e) { | ||
e.use(h, ee), e.renderer.rules.image = I.bind(e); | ||
e.use(h, ee), e.renderer.rules.image = Z.bind(e); | ||
} | ||
@@ -326,8 +326,10 @@ function g(e, r, s) { | ||
const { rules: r } = e.renderer, s = r.code_inline; | ||
r.code_inline = (t, n, i, o, l) => (t[n].attrPush(["class", "inline-code"]), s(t, n, i, o, l)); | ||
r.code_inline = function(t, n, ...i) { | ||
return t[n].attrPush(["class", "inline-code"]), s.call(this, t, n, ...i); | ||
}; | ||
} | ||
function Ne(e, r = {}) { | ||
return r.plain ? e.use(h) : (r.guest || e.use(ie), e.options.highlight ??= Z, e.use($), e.use(re), e.use(le)), r.guest ? e.use(oe) : e.use(y), e.use(ae).use(se); | ||
function Ge(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(le)), r.guest ? e.use(oe) : e.use(y), e.use(ae).use(se); | ||
} | ||
function Re(e, r) { | ||
function Ne(e, r) { | ||
function s(t) { | ||
@@ -351,19 +353,19 @@ for (const n of t) | ||
export { | ||
X as Emphasis, | ||
We as MarkdownIt, | ||
Q as Emphasis, | ||
Ue as MarkdownIt, | ||
ie as anchor, | ||
K as checkLink, | ||
V as checkLink, | ||
le as classify, | ||
se as collapsible, | ||
Re as collect, | ||
Q as defaultDirectiveMap, | ||
Ne as collect, | ||
K as defaultDirectiveMap, | ||
h as directive, | ||
$ as fence, | ||
w as fence, | ||
ae as footnote, | ||
Ge as getEmphasis, | ||
Z as highlight, | ||
Ne as kfmPreset, | ||
Ie as getEmphasis, | ||
Y as highlight, | ||
Ge as kfmPreset, | ||
re as media, | ||
Oe as toc, | ||
De as toc, | ||
oe as ugc | ||
}; |
@@ -7,7 +7,7 @@ import MarkdownIt from "markdown-it"; | ||
*/ | ||
export declare function ugc(markdownIt: MarkdownIt): void; | ||
export declare function ugc(md: MarkdownIt): void; | ||
/** | ||
* 给标题加上锚点,是对 markdown-it-anchor 的简单封装。 | ||
*/ | ||
export declare function anchor(markdownIt: MarkdownIt): void; | ||
export declare function anchor(md: MarkdownIt): void; | ||
/** | ||
@@ -26,7 +26,7 @@ * 在文章的末尾添加一段显示所有脚注。因为可能用于评论,所以修改渲染函数去掉横线, | ||
*/ | ||
export declare function footnote(markdownIt: MarkdownIt): void; | ||
export declare function footnote(md: MarkdownIt): void; | ||
/** | ||
* 给行内代码加个 inline-code 类以便跟代码块区分。 | ||
*/ | ||
export declare function classify(markdownIt: MarkdownIt): void; | ||
export declare function classify(md: MarkdownIt): void; | ||
export interface PresetOptions { | ||
@@ -49,2 +49,2 @@ /** | ||
*/ | ||
export declare function kfmPreset(markdownIt: MarkdownIt, options?: PresetOptions): MarkdownIt; | ||
export declare function kfmPreset(md: MarkdownIt, options?: PresetOptions): MarkdownIt; |
@@ -8,2 +8,2 @@ import type MarkdownIt from "markdown-it"; | ||
*/ | ||
export default function (markdownIt: MarkdownIt): void; | ||
export default function (md: MarkdownIt): void; |
{ | ||
"name": "@kaciras-blog/markdown", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"license": "MIT", | ||
@@ -21,14 +21,14 @@ "description": "Kaciras Flavored Markdown", | ||
"dependencies": { | ||
"@kaciras/utilities": "^0.10.2", | ||
"bootstrap-icons": "^1.11.1", | ||
"@kaciras/utilities": "^0.10.4", | ||
"bootstrap-icons": "^1.11.2", | ||
"highlight.js": "^11.9.0", | ||
"markdown-it": "^13.0.2", | ||
"markdown-it": "^14.0.0", | ||
"markdown-it-anchor": "^8.6.7", | ||
"markdown-it-footnote": "^3.0.3", | ||
"markdown-it-footnote": "^4.0.0", | ||
"markdown-it-toc-done-right": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/html-minifier-terser": "^7.0.1", | ||
"@types/markdown-it": "^13.0.5", | ||
"@vitest/coverage-v8": "^0.34.6", | ||
"@types/html-minifier-terser": "^7.0.2", | ||
"@types/markdown-it": "^13.0.7", | ||
"@vitest/coverage-v8": "^1.1.1", | ||
"html-minifier-terser": "^7.2.0", | ||
@@ -38,4 +38,4 @@ "magic-string": "^0.30.5", | ||
"postcss-simple-vars": "^7.0.1", | ||
"vite": "^4.5.0", | ||
"vitest": "^0.34.6" | ||
"vite": "^5.0.10", | ||
"vitest": "^1.1.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28315
621
0
+ Addedentities@4.5.0(transitive)
+ Addedlinkify-it@5.0.0(transitive)
+ Addedmarkdown-it@14.1.0(transitive)
+ Addedmarkdown-it-footnote@4.0.0(transitive)
+ Addedmdurl@2.0.0(transitive)
+ Addedpunycode.js@2.3.1(transitive)
+ Addeduc.micro@2.1.0(transitive)
- Removedentities@3.0.1(transitive)
- Removedlinkify-it@4.0.1(transitive)
- Removedmarkdown-it@13.0.2(transitive)
- Removedmarkdown-it-footnote@3.0.3(transitive)
- Removedmdurl@1.0.1(transitive)
- Removeduc.micro@1.0.6(transitive)
Updated@kaciras/utilities@^0.10.4
Updatedbootstrap-icons@^1.11.2
Updatedmarkdown-it@^14.0.0
Updatedmarkdown-it-footnote@^4.0.0