@kaciras-blog/markdown
Advanced tools
Comparing version 3.3.0 to 3.4.0
import MarkdownIt from "markdown-it"; | ||
import StateBlock from "markdown-it/lib/rules_block/state_block.mjs"; | ||
export declare function isWholeLine(state: StateBlock, lineNum: number, text: string): boolean; | ||
export declare function parseChildren(state: StateBlock, start: number, end: number, parent: string): void; | ||
export default function (md: MarkdownIt): void; |
import MarkdownIt from "markdown-it"; | ||
/** | ||
* 给块语法渲染的结果中添加原文行号信息,这样就能定位哪一行渲染出了哪个元素。 | ||
* 给块语法渲染的结果中添加原文行号信息,这样就能定位哪一行渲染出了哪个元素,可用于同步滚动。 | ||
* | ||
* 上游的解析器需要设置 `token.map` 属性,下游的渲染器也得将 `token.attrs` 添加到元素上。 | ||
* | ||
* @see https://github.com/microsoft/vscode/blob/1f94e5cd54ce0a7bc503a3f95a3742ddc5980151/extensions/markdown-language-features/src/markdownEngine.ts#L22 | ||
@@ -6,0 +8,0 @@ */ |
@@ -1,2 +0,1 @@ | ||
/// <reference types="markdown-it-toc-done-right" /> | ||
import "./web/markdown.css"; | ||
@@ -11,2 +10,3 @@ export * from "./directive.js"; | ||
export { default as directive } from "./directive.js"; | ||
export { default as div } from "./div.js"; | ||
export { default as collapsible } from "./collapsible.js"; | ||
@@ -13,0 +13,0 @@ export { default as fence } from "./web/fence.js"; |
369
lib/index.js
@@ -1,37 +0,37 @@ | ||
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 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"; | ||
import C from "highlight.js/lib/languages/dockerfile"; | ||
import S from "highlight.js/lib/languages/go"; | ||
import B from "highlight.js/lib/languages/http"; | ||
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 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 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; | ||
import { unescapeMd as h, escapeHtml as L } from "markdown-it/lib/common/utils.mjs"; | ||
import _ from "markdown-it-toc-done-right"; | ||
import { default as Qe } from "markdown-it-toc-done-right"; | ||
import k from "markdown-it-anchor"; | ||
import x from "markdown-it-footnote"; | ||
import { f as M } from "./fence-jxMdD6OG.js"; | ||
import c from "highlight.js/lib/core"; | ||
import A from "highlight.js/lib/languages/c"; | ||
import S from "highlight.js/lib/languages/cpp"; | ||
import C from "highlight.js/lib/languages/xml"; | ||
import j from "highlight.js/lib/languages/csharp"; | ||
import B from "highlight.js/lib/languages/css"; | ||
import z from "highlight.js/lib/languages/dockerfile"; | ||
import I from "highlight.js/lib/languages/go"; | ||
import T from "highlight.js/lib/languages/http"; | ||
import E from "highlight.js/lib/languages/ini"; | ||
import P from "highlight.js/lib/languages/java"; | ||
import F from "highlight.js/lib/languages/javascript"; | ||
import H from "highlight.js/lib/languages/json"; | ||
import W from "highlight.js/lib/languages/kotlin"; | ||
import R from "highlight.js/lib/languages/less"; | ||
import D from "highlight.js/lib/languages/lua"; | ||
import G from "highlight.js/lib/languages/protobuf"; | ||
import N from "highlight.js/lib/languages/python"; | ||
import q from "highlight.js/lib/languages/rust"; | ||
import J from "highlight.js/lib/languages/scss"; | ||
import O from "highlight.js/lib/languages/shell"; | ||
import U from "highlight.js/lib/languages/sql"; | ||
import V from "highlight.js/lib/languages/yaml"; | ||
import K from "highlight.js/lib/languages/typescript"; | ||
import { default as Ye } from "markdown-it"; | ||
function Q(e, r, n, t) { | ||
const s = e.tShift[r] + e.bMarks[r], o = e.src.slice(s, e.eMarks[r]); | ||
let i; | ||
try { | ||
o = V(i); | ||
i = X(o); | ||
} catch { | ||
@@ -41,12 +41,12 @@ return !1; | ||
if (!t) { | ||
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)]]; | ||
const { type: a, label: l, href: u, attrs: g } = i, f = e.push("directive", a, 0); | ||
f.meta = g, f.content = l, f.map = [r, r + 1], f.attrs = [["src", Y(e.md, u)]]; | ||
} | ||
return e.line = r + 1, !0; | ||
} | ||
function V(e) { | ||
function X(e) { | ||
const r = /^@([a-z][a-z0-9\-_]*)/i.exec(e); | ||
if (!r) | ||
throw new Error("Not a directive syntax."); | ||
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; | ||
const [{ length: n }, t] = r, s = b(e, n, 91, 93), o = b(e, s + 1, 40, 41), i = h(e.slice(n + 1, s)), a = h(e.slice(s + 2, o)), l = o + 1; | ||
let u = {}; | ||
@@ -57,8 +57,8 @@ if (e.charCodeAt(l) === 123) | ||
throw new Error("Extra strings after the directive."); | ||
return { type: t, label: o, href: c, attrs: u }; | ||
return { type: t, label: i, href: a, attrs: u }; | ||
} | ||
function h(e, r, n, t) { | ||
function b(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}`); | ||
const o = String.fromCharCode(n), i = e.charAt(r); | ||
throw new Error(`Expect ${o}, but found ${i}`); | ||
} | ||
@@ -78,11 +78,10 @@ let s = 1; | ||
} | ||
if (s === 0) | ||
return r; | ||
if (s === 0) return r; | ||
} | ||
throw new Error(`Bracket count does not match, level=${s}`); | ||
} | ||
function K(e, r) { | ||
function Y(e, r) { | ||
return r = e.normalizeLink(r), e.validateLink(r) ? r : ""; | ||
} | ||
const Q = { | ||
const Z = { | ||
audio(e) { | ||
@@ -100,15 +99,15 @@ return `<audio${this.renderAttrs(e)} controls></audio>`; | ||
}; | ||
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); | ||
function v(e, r = Z) { | ||
e.renderer.rules.directive = (n, t, s, o, i) => { | ||
const a = n[t], l = r[a.tag]; | ||
return l ? l.call(i, a, e, o) : `[Unknown directive: ${a.tag}]`; | ||
}, e.block.ruler.before("html_block", "directive", Q); | ||
} | ||
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); | ||
var ee = /* @__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))(ee || {}); | ||
function qe(e) { | ||
let r = 0, n = 0, t = e.length - 1, s = 0, o = e.charCodeAt(0); | ||
if (t < 1) | ||
return [0, 0]; | ||
function o() { | ||
return s === 0 ? 0 : i === 126 && s === 2 ? 8 : i === 96 ? 4 : i !== 42 && i !== 95 ? 0 : s === 1 ? 1 : s === 2 ? 2 : 3; | ||
function i() { | ||
return s === 0 ? 0 : o === 126 && s === 2 ? 8 : o === 96 ? 4 : o !== 42 && o !== 95 ? 0 : s === 1 ? 1 : s === 2 ? 2 : 3; | ||
} | ||
@@ -119,13 +118,13 @@ for (; n < t; n++, t--, s++) { | ||
break; | ||
if (l !== i) { | ||
const u = o(); | ||
if (l !== o) { | ||
const u = i(); | ||
if (u === 0) | ||
break; | ||
s = 0, i = l, r |= u; | ||
s = 0, o = l, r |= u; | ||
} | ||
} | ||
const c = o(); | ||
return [r | c, c === 0 ? n - s : n]; | ||
const a = i(); | ||
return [r | a, a === 0 ? n - s : n]; | ||
} | ||
function Y(e) { | ||
function re(e) { | ||
return { | ||
@@ -182,41 +181,41 @@ subLanguage: "xml", | ||
} | ||
a.registerLanguage("c", x); | ||
a.registerLanguage("cpp", _); | ||
a.registerLanguage("xml", A); | ||
a.registerLanguage("cs", M); | ||
a.registerLanguage("css", j); | ||
a.registerLanguage("dockerfile", C); | ||
a.registerLanguage("go", S); | ||
a.registerLanguage("http", B); | ||
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", 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", Y); | ||
function Z(e, r, n) { | ||
if (!a.getLanguage(r)) | ||
return y(e); | ||
c.registerLanguage("c", A); | ||
c.registerLanguage("cpp", S); | ||
c.registerLanguage("xml", C); | ||
c.registerLanguage("cs", j); | ||
c.registerLanguage("css", B); | ||
c.registerLanguage("dockerfile", z); | ||
c.registerLanguage("go", I); | ||
c.registerLanguage("http", T); | ||
c.registerLanguage("ini", E); | ||
c.registerLanguage("java", P); | ||
c.registerLanguage("javascript", F); | ||
c.registerLanguage("json", H); | ||
c.registerLanguage("kotlin", W); | ||
c.registerLanguage("less", R); | ||
c.registerLanguage("lua", D); | ||
c.registerLanguage("protobuf", G); | ||
c.registerLanguage("python", N); | ||
c.registerLanguage("rust", q); | ||
c.registerLanguage("scss", J); | ||
c.registerLanguage("shell", O); | ||
c.registerLanguage("sql", U); | ||
c.registerLanguage("yaml", V); | ||
c.registerLanguage("typescript", K); | ||
c.registerLanguage("vue", re); | ||
function te(e, r, n) { | ||
if (!c.getLanguage(r)) | ||
return L(e); | ||
if (n !== "diff") | ||
return a.highlight(e, { language: r }).value; | ||
return c.highlight(e, { language: r }).value; | ||
let t = e.split(` | ||
`); | ||
const s = /* @__PURE__ */ new Map(); | ||
for (let o = 0; o < t.length; o++) { | ||
switch (t[o].charCodeAt(0)) { | ||
for (let i = 0; i < t.length; i++) { | ||
switch (t[i].charCodeAt(0)) { | ||
case 43: | ||
s.set(o, !0); | ||
s.set(i, !0); | ||
break; | ||
case 45: | ||
s.set(o, !1); | ||
s.set(i, !1); | ||
break; | ||
@@ -226,41 +225,41 @@ default: | ||
} | ||
t[o] = t[o].slice(1); | ||
t[i] = t[i].slice(1); | ||
} | ||
e = t.join(` | ||
`), e = a.highlight(e, { language: r }).value, t = e.split(` | ||
`), e = c.highlight(e, { language: r }).value, t = e.split(` | ||
`); | ||
const i = []; | ||
for (let o = 0; o < t.length; o++) { | ||
switch (s.has(o - 1) && i.push("</span>"), s.get(o)) { | ||
const o = []; | ||
for (let i = 0; i < t.length; i++) { | ||
switch (s.has(i - 1) && o.push("</span>"), s.get(i)) { | ||
case !0: | ||
i.push("<span class='hljs-insert'>"); | ||
o.push("<span class='hljs-insert'>"); | ||
break; | ||
case !1: | ||
i.push("<span class='hljs-delete'>"); | ||
o.push("<span class='hljs-delete'>"); | ||
break; | ||
} | ||
i.push(t[o], ` | ||
o.push(t[i], ` | ||
`); | ||
} | ||
return i.pop(), i.join(""); | ||
return o.pop(), o.join(""); | ||
} | ||
function b(e) { | ||
function y(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 f(e, r) { | ||
function d(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()]; | ||
} | ||
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>`; | ||
function ne(e, r, n, t, s) { | ||
const o = e[r]; | ||
o.attrs.splice(o.attrIndex("alt"), 1); | ||
const [i, a] = d(s, o), l = this.utils.escapeHtml(o.content); | ||
return `<span ${a}><a ${y(i)} class="md-inspect" href="${i}" rel="noopener" target="_blank"><img data-src="${i}" alt="${l}" class="md-img" crossorigin></a>${l ? `<span class="md-alt">${l}</span>` : ""}</span>`; | ||
} | ||
const re = { | ||
const se = { | ||
// 大部分浏览器只允许无声视频自动播放,不过 GIF 视频本来就是无声的。 | ||
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>`; | ||
const n = r.utils.escapeHtml(e.content), [t, s] = d(this, e); | ||
return `<p ${s}><video ${y(t)} class="gif" crossorigin loop muted data-src="${t}"></video>${n ? `<span class="md-alt">${n}</span>` : ""}</p>`; | ||
}, | ||
@@ -270,75 +269,100 @@ video(e, r) { | ||
r.validateLink(n) || (n = ""); | ||
const [t, s] = f(this, e); | ||
const [t, s] = d(this, e); | ||
return `<p ${s}><video class="md-video" controls crossorigin poster="${n}" data-src="${t}"></video></p>`; | ||
}, | ||
audio(e, r) { | ||
const n = r.utils.escapeHtml(e.content), [t, s] = f(this, e); | ||
const n = r.utils.escapeHtml(e.content), [t, s] = d(this, e); | ||
return `<p ${s}><audio controls data-src="${t}" crossorigin></audio>${n ? `<span class="md-alt">${n}</span>` : ""}</p>`; | ||
} | ||
}; | ||
function te(e) { | ||
e.use(k, re), e.renderer.rules.image = ee.bind(e); | ||
function oe(e) { | ||
e.use(v, se), e.renderer.rules.image = ne.bind(e); | ||
} | ||
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 p(e, r, n) { | ||
const { src: t, bMarks: s, tShift: o, eMarks: i } = e, a = s[r] + o[r], l = i[r]; | ||
return a + n.length === l && t.startsWith(n, a); | ||
} | ||
function ne(e, r, n) { | ||
if (!g(e, r, "<details>")) | ||
function $(e, r, n, t) { | ||
const s = e.parentType, o = e.lineMax; | ||
e.parentType = t, e.lineMax = n, e.md.block.tokenize(e, r, n), e.lineMax = o, e.parentType = s; | ||
} | ||
function ie(e, r, n) { | ||
if (!p(e, r, "<details>")) | ||
return !1; | ||
let t = r + 1, s = 1; | ||
for (; t < n && s > 0; t++) | ||
g(e, t, "<details>") ? s += 1 : g(e, t, "</details>") && (s -= 1); | ||
p(e, t, "<details>") ? s += 1 : p(e, t, "</details>") && (s -= 1); | ||
if (s !== 0) | ||
return !1; | ||
const i = e.parentType, o = e.lineMax; | ||
e.parentType = "collapsible", e.lineMax = t - 1; | ||
let c = e.push("collapsible_open", "details", 1); | ||
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; | ||
let o = e.push("collapsible_open", "details", 1); | ||
return o.block = !0, o.markup = "<details>", o.map = [r, t], $(e, r + 1, t - 1, "collapsible"), o = e.push("collapsible_close", "details", -1), o.block = !0, o.markup = "</details>", e.line = t, !0; | ||
} | ||
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") | ||
function ce(e, r, n) { | ||
const { src: t, bMarks: s, eMarks: o } = e; | ||
if (!p(e, r, "<summary>") || e.tokens.at(-1)?.type !== "collapsible_open") | ||
return !1; | ||
let o = r += 1; | ||
for (; o < n && !g(e, o, "</summary>"); o++) | ||
let i = r += 1; | ||
for (; i < n && !p(e, i, "</summary>"); i++) | ||
; | ||
e.push("summary_open", "summary", 1); | ||
const c = e.push("inline", "", 0); | ||
return c.children = [], c.content = t.slice(s[r], i[o - 1]), e.push("summary_close", "summary", -1), e.line = o + 1, !0; | ||
const a = e.push("inline", "", 0); | ||
return a.children = [], a.content = t.slice(s[r], o[i - 1]), e.push("summary_close", "summary", -1), e.line = i + 1, !0; | ||
} | ||
function oe(e) { | ||
e.block.ruler.before("fence", "collapsible", ne), e.block.ruler.before("fence", "summary", se); | ||
function ae(e) { | ||
e.block.ruler.before("fence", "collapsible", ie), e.block.ruler.before("fence", "summary", ce); | ||
} | ||
function ie(e) { | ||
function le(e, r, n) { | ||
const { src: t, bMarks: s, tShift: o, eMarks: i } = e, a = o[r] + s[r]; | ||
if (!t.startsWith("::: ", a)) | ||
return !1; | ||
const l = e.src.slice(a + 4, i[r]); | ||
if (!l) | ||
return !1; | ||
let u = r + 1, g = 1; | ||
for (; u < n && g > 0; u++) { | ||
const m = s[u] + o[u], w = i[u]; | ||
t.startsWith("::: ", m) && m + 4 !== w ? g += 1 : p(e, u, ":::") && (g -= 1); | ||
} | ||
if (g !== 0) | ||
return !1; | ||
let f = e.push("div_open", "div", 1); | ||
return f.attrSet("class", `alert ${l}`), f.block = !0, f.markup = "<div>", f.map = [r, u], $(e, r + 1, u - 1, "div"), f = e.push("div_close", "div", -1), f.block = !0, f.markup = "</div>", e.line = u, !0; | ||
} | ||
function ue(e) { | ||
e.block.ruler.before("fence", "div", le); | ||
} | ||
function fe(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); | ||
r.renderToken = function(t, s, o) { | ||
const i = t[s]; | ||
return i.type === "link_open" && i.attrPush(["rel", "ugc,nofollow"]), n.call(this, t, s, o); | ||
}; | ||
} | ||
function ae(e) { | ||
e.use(d, { | ||
permalink: d.permalink.linkInsideHeader({ | ||
function ge(e) { | ||
e.use(k, { | ||
permalink: k.permalink.linkInsideHeader({ | ||
placement: "after", | ||
class: "anchor-link" | ||
}), | ||
slugify: (r) => r.trim().toLowerCase().replace(/\s+/g, "-") | ||
slugifyWithState(r, n) { | ||
const { docId: t } = n.env; | ||
return r = r.trim().toLowerCase().replace(/\s+/g, "-"), t ? `${t}-${r}` : r; | ||
} | ||
}); | ||
} | ||
function ce(e) { | ||
e.use(w); | ||
function pe(e) { | ||
e.use(x); | ||
const { rules: r } = e.renderer; | ||
r.footnote_block_open = () => "<h2 class='footnotes'></h2><ol class='footnotes-list'>", r.footnote_block_close = () => "</ol>"; | ||
} | ||
function le(e) { | ||
function de(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); | ||
r.table_open = () => '<div class="table-view"><table>', r.table_close = () => "</table></div>", r.code_inline = function(t, s, ...o) { | ||
return t[s].attrPush(["class", "inline-code"]), n.call(this, t, s, ...o); | ||
}; | ||
} | ||
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 Je(e, r = {}) { | ||
return r.plain ? e.use(v) : (r.guest || e.use(ge), e.options.highlight ??= te, e.use(M), e.use(oe), e.use(de)), r.guest ? e.use(fe) : e.use(_), e.use(ue).use(pe).use(ae); | ||
} | ||
function Ne(e) { | ||
function Oe(e) { | ||
e.core.ruler.push("source-line", (r) => { | ||
@@ -352,3 +376,3 @@ for (const n of r.tokens) | ||
} | ||
function Re(e, r) { | ||
function Ue(e, r) { | ||
function n(t) { | ||
@@ -372,20 +396,21 @@ for (const s of t) | ||
export { | ||
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 | ||
ee as Emphasis, | ||
Ye as MarkdownIt, | ||
ge as anchor, | ||
ae as collapsible, | ||
Ue as collect, | ||
Z as defaultDirectiveMap, | ||
v as directive, | ||
ue as div, | ||
M as fence, | ||
pe as footnote, | ||
qe as getEmphasis, | ||
te as highlight, | ||
Je as kfmPreset, | ||
oe as media, | ||
X as parseGenericDirective, | ||
Oe as sourceLine, | ||
de as styling, | ||
Qe as toc, | ||
fe as ugc | ||
}; |
@@ -9,3 +9,5 @@ import MarkdownIt from "markdown-it"; | ||
/** | ||
* 给标题加上锚点,是对 markdown-it-anchor 的简单封装。 | ||
* 给标题加上锚点,是对 markdown-it-anchor 的简单封装,做了一些自定义: | ||
* - 链接元素放到了后面,让布局更容易。 | ||
* - 可以设置 env.docId 参数来给链接加前缀,避免单页里多个文章的锚点重复。 | ||
*/ | ||
@@ -28,5 +30,8 @@ export declare function anchor(md: MarkdownIt): void; | ||
/** | ||
* 给行内代码加个 inline-code 类以便跟代码块区分。 | ||
* 一些小的、通用的调整,为了方便加样式,因为每个都没几行所以放一起了。 | ||
* | ||
* - 行内代码加个 inline-code 类以便跟代码块区分。 | ||
* - 表格外层套上 div 这样就能加滚动条。 | ||
*/ | ||
export declare function classify(md: MarkdownIt): void; | ||
export declare function styling(md: MarkdownIt): void; | ||
export interface PresetOptions { | ||
@@ -33,0 +38,0 @@ /** |
{ | ||
"name": "@kaciras-blog/markdown", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"license": "MIT", | ||
@@ -21,7 +21,7 @@ "description": "Kaciras Flavored Markdown", | ||
"dependencies": { | ||
"@kaciras/utilities": "^0.13.0", | ||
"@kaciras/utilities": "^1.0.3", | ||
"bootstrap-icons": "^1.11.3", | ||
"highlight.js": "^11.9.0", | ||
"highlight.js": "^11.10.0", | ||
"markdown-it": "^14.1.0", | ||
"markdown-it-anchor": "^9.0.1", | ||
"markdown-it-anchor": "^9.1.0", | ||
"markdown-it-footnote": "^4.0.0", | ||
@@ -32,10 +32,11 @@ "markdown-it-toc-done-right": "^4.2.0" | ||
"@types/html-minifier-terser": "^7.0.2", | ||
"@types/markdown-it": "^14.1.1", | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"@types/markdown-it": "^14.1.2", | ||
"@vitest/coverage-v8": "^2.0.5", | ||
"dedent": "^1.5.3", | ||
"html-minifier-terser": "^7.2.0", | ||
"magic-string": "^0.30.10", | ||
"postcss-nested": "^6.0.1", | ||
"magic-string": "^0.30.11", | ||
"postcss-nested": "^6.2.0", | ||
"postcss-simple-vars": "^7.0.1", | ||
"vite": "^5.2.11", | ||
"vitest": "^1.6.0" | ||
"vite": "^5.4.3", | ||
"vitest": "^2.0.5" | ||
}, | ||
@@ -42,0 +43,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
32443
19
707
10
+ Added@kaciras/utilities@1.0.4(transitive)
- Removed@kaciras/utilities@0.13.1(transitive)
Updated@kaciras/utilities@^1.0.3
Updatedhighlight.js@^11.10.0
Updatedmarkdown-it-anchor@^9.1.0