@rbbtsn0w/wechat-markdown 1.1.1
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/README.md +176 -0
- package/dist/engine.d.ts +33 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +289 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/inliner/dom-patcher.d.ts +4 -0
- package/dist/inliner/dom-patcher.d.ts.map +1 -0
- package/dist/inliner/dom-patcher.js +46 -0
- package/dist/inliner/dom-patcher.js.map +1 -0
- package/dist/inliner/inliner.d.ts +14 -0
- package/dist/inliner/inliner.d.ts.map +1 -0
- package/dist/inliner/inliner.js +35 -0
- package/dist/inliner/inliner.js.map +1 -0
- package/dist/media/formula.d.ts +8 -0
- package/dist/media/formula.d.ts.map +1 -0
- package/dist/media/formula.js +54 -0
- package/dist/media/formula.js.map +1 -0
- package/dist/media/mermaid.d.ts +8 -0
- package/dist/media/mermaid.d.ts.map +1 -0
- package/dist/media/mermaid.js +45 -0
- package/dist/media/mermaid.js.map +1 -0
- package/dist/media/styles.d.ts +17 -0
- package/dist/media/styles.d.ts.map +1 -0
- package/dist/media/styles.js +47 -0
- package/dist/media/styles.js.map +1 -0
- package/dist/plugins/alerts.d.ts +29 -0
- package/dist/plugins/alerts.d.ts.map +1 -0
- package/dist/plugins/alerts.js +79 -0
- package/dist/plugins/alerts.js.map +1 -0
- package/dist/plugins/code-decorator.d.ts +8 -0
- package/dist/plugins/code-decorator.d.ts.map +1 -0
- package/dist/plugins/code-decorator.js +73 -0
- package/dist/plugins/code-decorator.js.map +1 -0
- package/dist/plugins/footnotes.d.ts +16 -0
- package/dist/plugins/footnotes.d.ts.map +1 -0
- package/dist/plugins/footnotes.js +103 -0
- package/dist/plugins/footnotes.js.map +1 -0
- package/dist/plugins/table-scroller.d.ts +7 -0
- package/dist/plugins/table-scroller.d.ts.map +1 -0
- package/dist/plugins/table-scroller.js +24 -0
- package/dist/plugins/table-scroller.js.map +1 -0
- package/dist/themes/geek.d.ts +2 -0
- package/dist/themes/geek.d.ts.map +1 -0
- package/dist/themes/geek.js +147 -0
- package/dist/themes/geek.js.map +1 -0
- package/dist/themes/grace.d.ts +2 -0
- package/dist/themes/grace.d.ts.map +1 -0
- package/dist/themes/grace.js +148 -0
- package/dist/themes/grace.js.map +1 -0
- package/dist/themes/index.d.ts +12 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +48 -0
- package/dist/themes/index.js.map +1 -0
- package/dist/themes/tech.d.ts +2 -0
- package/dist/themes/tech.d.ts.map +1 -0
- package/dist/themes/tech.js +253 -0
- package/dist/themes/tech.js.map +1 -0
- package/dist/types/index.d.ts +75 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.inlineWechatCss = inlineWechatCss;
|
|
7
|
+
const juice_1 = __importDefault(require("juice"));
|
|
8
|
+
const dom_patcher_1 = require("./dom-patcher");
|
|
9
|
+
const themes_1 = require("../themes");
|
|
10
|
+
function inlineWechatCss(html, options = {}) {
|
|
11
|
+
// 1. Sanitize
|
|
12
|
+
let processedHtml = (0, dom_patcher_1.sanitizeWechatHtml)(html);
|
|
13
|
+
// 2. Resolve relative URLs if siteUrl is specified
|
|
14
|
+
if (options.siteUrl) {
|
|
15
|
+
const base = options.siteUrl.replace(/\/$/, '');
|
|
16
|
+
processedHtml = processedHtml.replace(/(<a\s+[^>]*href=")(\/[^"]*)(")/g, (match, p1, p2, p3) => {
|
|
17
|
+
return `${p1}${base}${p2}${p3}`;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
// 3. Wrap in container for CSS matching
|
|
21
|
+
const wrappedHtml = `<div class="markdown-body">${processedHtml}</div>`;
|
|
22
|
+
// 4. Layer capability base CSS under the theme (and customCss on top)
|
|
23
|
+
const themeCss = (0, themes_1.getTheme)(options.theme, options.customCss);
|
|
24
|
+
const css = [...(options.baseCss ?? []), themeCss].join('\n');
|
|
25
|
+
// 5. Juice CSS Inlining
|
|
26
|
+
const inlined = juice_1.default.inlineContent(wrappedHtml, css, {
|
|
27
|
+
inlinePseudoElements: true,
|
|
28
|
+
preserveImportant: true,
|
|
29
|
+
});
|
|
30
|
+
// 6. Patch WeChat DOM quirks & clean attributes
|
|
31
|
+
let finalHtml = (0, dom_patcher_1.cleanWechatAttributes)(inlined);
|
|
32
|
+
finalHtml = (0, dom_patcher_1.patchWechatListBullets)(finalHtml);
|
|
33
|
+
return finalHtml;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=inliner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inliner.js","sourceRoot":"","sources":["../../src/inliner/inliner.ts"],"names":[],"mappings":";;;;;AAiBA,0CA8BC;AA/CD,kDAA0B;AAC1B,+CAAkG;AAClG,sCAAqC;AAerC,SAAgB,eAAe,CAAC,IAAY,EAAE,UAAyB,EAAE;IACvE,cAAc;IACd,IAAI,aAAa,GAAG,IAAA,gCAAkB,EAAC,IAAI,CAAC,CAAC;IAE7C,mDAAmD;IACnD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChD,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,iCAAiC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;YAC7F,OAAO,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,wCAAwC;IACxC,MAAM,WAAW,GAAG,8BAA8B,aAAa,QAAQ,CAAC;IAExE,sEAAsE;IACtE,MAAM,QAAQ,GAAG,IAAA,iBAAQ,EAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE9D,wBAAwB;IACxB,MAAM,OAAO,GAAG,eAAK,CAAC,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE;QACpD,oBAAoB,EAAE,IAAI;QAC1B,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;IAEH,gDAAgD;IAChD,IAAI,SAAS,GAAG,IAAA,mCAAqB,EAAC,OAAO,CAAC,CAAC;IAC/C,SAAS,GAAG,IAAA,oCAAsB,EAAC,SAAS,CAAC,CAAC;IAE9C,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class FormulaRenderer {
|
|
2
|
+
private tempDir;
|
|
3
|
+
constructor(tempDir?: string);
|
|
4
|
+
getHash(expression: string, display: boolean): string;
|
|
5
|
+
getTargetPath(hash: string): string;
|
|
6
|
+
renderToImage(expression: string, display: boolean): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=formula.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula.d.ts","sourceRoot":"","sources":["../../src/media/formula.ts"],"names":[],"mappings":"AAWA,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,CAAC,EAAE,MAAM;IAO5B,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM;IAIrD,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI7B,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;CAuB3E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FormulaRenderer = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
12
|
+
const mathjax_js_1 = require("mathjax-full/js/mathjax.js");
|
|
13
|
+
const tex_js_1 = require("mathjax-full/js/input/tex.js");
|
|
14
|
+
const svg_js_1 = require("mathjax-full/js/output/svg.js");
|
|
15
|
+
const liteAdaptor_js_1 = require("mathjax-full/js/adaptors/liteAdaptor.js");
|
|
16
|
+
const html_js_1 = require("mathjax-full/js/handlers/html.js");
|
|
17
|
+
class FormulaRenderer {
|
|
18
|
+
tempDir;
|
|
19
|
+
constructor(tempDir) {
|
|
20
|
+
this.tempDir = tempDir || path_1.default.join(os_1.default.tmpdir(), 'wechat-markdown-formulas');
|
|
21
|
+
if (!fs_1.default.existsSync(this.tempDir)) {
|
|
22
|
+
fs_1.default.mkdirSync(this.tempDir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getHash(expression, display) {
|
|
26
|
+
return crypto_1.default.createHash('sha256').update(`${display ? 'display' : 'inline'}:${expression}`).digest('hex');
|
|
27
|
+
}
|
|
28
|
+
getTargetPath(hash) {
|
|
29
|
+
return path_1.default.join(this.tempDir, `${hash}.png`);
|
|
30
|
+
}
|
|
31
|
+
async renderToImage(expression, display) {
|
|
32
|
+
const hash = this.getHash(expression, display);
|
|
33
|
+
const targetPath = this.getTargetPath(hash);
|
|
34
|
+
if (fs_1.default.existsSync(targetPath)) {
|
|
35
|
+
return targetPath;
|
|
36
|
+
}
|
|
37
|
+
const adaptor = (0, liteAdaptor_js_1.liteAdaptor)();
|
|
38
|
+
(0, html_js_1.RegisterHTMLHandler)(adaptor);
|
|
39
|
+
const tex = new tex_js_1.TeX({ packages: ['base', 'ams'] });
|
|
40
|
+
const svgOutput = new svg_js_1.SVG({ fontCache: 'none' });
|
|
41
|
+
const document = mathjax_js_1.mathjax.document('', { InputJax: tex, OutputJax: svgOutput });
|
|
42
|
+
const node = document.convert(expression, { display });
|
|
43
|
+
const rendered = adaptor.outerHTML(node);
|
|
44
|
+
const svg = rendered.match(/<svg[\s\S]*<\/svg>/)?.[0];
|
|
45
|
+
if (!svg) {
|
|
46
|
+
throw new Error('MathJax did not produce an SVG image.');
|
|
47
|
+
}
|
|
48
|
+
const png = await (0, sharp_1.default)(Buffer.from(svg)).png().toBuffer();
|
|
49
|
+
fs_1.default.writeFileSync(targetPath, png);
|
|
50
|
+
return targetPath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FormulaRenderer = FormulaRenderer;
|
|
54
|
+
//# sourceMappingURL=formula.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula.js","sourceRoot":"","sources":["../../src/media/formula.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AACpB,oDAA4B;AAC5B,kDAA0B;AAC1B,2DAAqD;AACrD,yDAAmD;AACnD,0DAAoD;AACpD,4EAAsE;AACtE,8DAAuE;AAEvE,MAAa,eAAe;IAClB,OAAO,CAAS;IAExB,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,0BAA0B,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,OAAO,CAAC,UAAkB,EAAE,OAAgB;QAC1C,OAAO,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7G,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAkB,EAAE,OAAgB;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,OAAO,GAAG,IAAA,4BAAW,GAAE,CAAC;QAC9B,IAAA,6BAAmB,EAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,IAAI,YAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QACnD,MAAM,SAAS,GAAG,IAAI,YAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,oBAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/E,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAA,eAAK,EAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC3D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAClC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAzCD,0CAyCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class MermaidRenderer {
|
|
2
|
+
private tempDir;
|
|
3
|
+
constructor(tempDir?: string);
|
|
4
|
+
getHash(mermaidCode: string): string;
|
|
5
|
+
getTargetPath(hash: string): string;
|
|
6
|
+
renderToImage(mermaidCode: string): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../src/media/mermaid.ts"],"names":[],"mappings":"AAOA,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,CAAC,EAAE,MAAM;IAO5B,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAIpC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI7B,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqB1D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MermaidRenderer = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
const pako_1 = __importDefault(require("pako"));
|
|
13
|
+
class MermaidRenderer {
|
|
14
|
+
tempDir;
|
|
15
|
+
constructor(tempDir) {
|
|
16
|
+
this.tempDir = tempDir || path_1.default.join(os_1.default.tmpdir(), 'wechat-markdown-mermaid');
|
|
17
|
+
if (!fs_1.default.existsSync(this.tempDir)) {
|
|
18
|
+
fs_1.default.mkdirSync(this.tempDir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
getHash(mermaidCode) {
|
|
22
|
+
return crypto_1.default.createHash('md5').update(mermaidCode.trim()).digest('hex');
|
|
23
|
+
}
|
|
24
|
+
getTargetPath(hash) {
|
|
25
|
+
return path_1.default.join(this.tempDir, `${hash}.png`);
|
|
26
|
+
}
|
|
27
|
+
async renderToImage(mermaidCode) {
|
|
28
|
+
const hash = this.getHash(mermaidCode);
|
|
29
|
+
const targetPath = this.getTargetPath(hash);
|
|
30
|
+
if (fs_1.default.existsSync(targetPath)) {
|
|
31
|
+
return targetPath;
|
|
32
|
+
}
|
|
33
|
+
const data = Buffer.from(mermaidCode.trim(), 'utf8');
|
|
34
|
+
const compressed = pako_1.default.deflate(data, { level: 9 });
|
|
35
|
+
const result = Buffer.from(compressed).toString('base64')
|
|
36
|
+
.replace(/\+/g, '-')
|
|
37
|
+
.replace(/\//g, '_');
|
|
38
|
+
const url = `https://kroki.io/mermaid/png/${result}`;
|
|
39
|
+
const response = await axios_1.default.get(url, { responseType: 'arraybuffer', timeout: 10000 });
|
|
40
|
+
fs_1.default.writeFileSync(targetPath, response.data);
|
|
41
|
+
return targetPath;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.MermaidRenderer = MermaidRenderer;
|
|
45
|
+
//# sourceMappingURL=mermaid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../../src/media/mermaid.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AACpB,oDAA4B;AAC5B,kDAA0B;AAC1B,gDAAwB;AAExB,MAAa,eAAe;IAClB,OAAO,CAAS;IAExB,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,yBAAyB,CAAC,CAAC;QAC5E,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,OAAO,CAAC,WAAmB;QACzB,OAAO,gBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3E,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAE5C,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;aACtD,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEvB,MAAM,GAAG,GAAG,gCAAgC,MAAM,EAAE,CAAC;QAErD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACvF,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE5C,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAvCD,0CAuCC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural styling for the <img>/<p> markup the engine emits for rendered
|
|
3
|
+
* formulas and Mermaid diagrams.
|
|
4
|
+
*
|
|
5
|
+
* These selectors are deliberately scoped as `.markdown-body img.wm-xxx`
|
|
6
|
+
* (specificity 0,2,1) rather than a bare `.wm-xxx` (0,1,0). Themes commonly
|
|
7
|
+
* declare `.markdown-body img { ... }` (0,1,1) -- see themes/tech.ts -- which
|
|
8
|
+
* outranks a bare class regardless of concatenation order and would force a
|
|
9
|
+
* block formula onto its own line. The properties a theme's `img` rule
|
|
10
|
+
* declares but these rules do not (e.g. border-radius) still flow through,
|
|
11
|
+
* which is what keeps a themed formula visually consistent with other images.
|
|
12
|
+
*
|
|
13
|
+
* Must never use !important -- themes are layered after this and would lose.
|
|
14
|
+
*/
|
|
15
|
+
export declare const formulaBaseCss = "\n.markdown-body p.wm-figure {\n text-align: center;\n}\n\n.markdown-body img.wm-formula-inline {\n display: inline-block;\n vertical-align: middle;\n margin: 0 2px;\n max-height: 1.4em;\n}\n\n.markdown-body img.wm-formula-block {\n display: inline-block;\n max-width: 90%;\n margin: 12px auto;\n}\n";
|
|
16
|
+
export declare const mermaidBaseCss = "\n.markdown-body p.wm-figure {\n text-align: center;\n}\n\n.markdown-body img.wm-mermaid {\n display: block;\n max-width: 100%;\n margin: 12px auto;\n}\n";
|
|
17
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/media/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,wTAiB1B,CAAC;AAEF,eAAO,MAAM,cAAc,kKAU1B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mermaidBaseCss = exports.formulaBaseCss = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Structural styling for the <img>/<p> markup the engine emits for rendered
|
|
6
|
+
* formulas and Mermaid diagrams.
|
|
7
|
+
*
|
|
8
|
+
* These selectors are deliberately scoped as `.markdown-body img.wm-xxx`
|
|
9
|
+
* (specificity 0,2,1) rather than a bare `.wm-xxx` (0,1,0). Themes commonly
|
|
10
|
+
* declare `.markdown-body img { ... }` (0,1,1) -- see themes/tech.ts -- which
|
|
11
|
+
* outranks a bare class regardless of concatenation order and would force a
|
|
12
|
+
* block formula onto its own line. The properties a theme's `img` rule
|
|
13
|
+
* declares but these rules do not (e.g. border-radius) still flow through,
|
|
14
|
+
* which is what keeps a themed formula visually consistent with other images.
|
|
15
|
+
*
|
|
16
|
+
* Must never use !important -- themes are layered after this and would lose.
|
|
17
|
+
*/
|
|
18
|
+
exports.formulaBaseCss = `
|
|
19
|
+
.markdown-body p.wm-figure {
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.markdown-body img.wm-formula-inline {
|
|
24
|
+
display: inline-block;
|
|
25
|
+
vertical-align: middle;
|
|
26
|
+
margin: 0 2px;
|
|
27
|
+
max-height: 1.4em;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.markdown-body img.wm-formula-block {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
max-width: 90%;
|
|
33
|
+
margin: 12px auto;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
exports.mermaidBaseCss = `
|
|
37
|
+
.markdown-body p.wm-figure {
|
|
38
|
+
text-align: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.markdown-body img.wm-mermaid {
|
|
42
|
+
display: block;
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
margin: 12px auto;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/media/styles.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACU,QAAA,cAAc,GAAG;;;;;;;;;;;;;;;;;CAiB7B,CAAC;AAEW,QAAA,cAAc,GAAG;;;;;;;;;;CAU7B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural styling for the markup this plugin emits. See the note on
|
|
3
|
+
* codeDecoratorBaseCss about the no-!important rule.
|
|
4
|
+
*
|
|
5
|
+
* The alert selectors are deliberately scoped as
|
|
6
|
+
* `.markdown-body blockquote.gfm-alert-note` (specificity 0,2,1) rather than a
|
|
7
|
+
* bare `.gfm-alert-note` (0,1,0). Every built-in theme declares
|
|
8
|
+
* `.markdown-body blockquote { background-color: ...; border-left: ... }`
|
|
9
|
+
* (0,1,1) -- see themes/tech.ts -- which outranks a bare class regardless of
|
|
10
|
+
* concatenation order and collapsed all five alert types onto one generic
|
|
11
|
+
* blockquote look. (A minimal custom theme that skips blockquote styling
|
|
12
|
+
* entirely wouldn't hit this, but the scoped selector is harmless for it too.)
|
|
13
|
+
* Same defect class as the `img.wm-formula-*` rules; the rationale block in
|
|
14
|
+
* media/styles.ts covers it in full.
|
|
15
|
+
*
|
|
16
|
+
* Consequence for themes: a theme that wants to restyle alerts must match this
|
|
17
|
+
* shape (`.markdown-body blockquote.gfm-alert-note`), because a bare
|
|
18
|
+
* `.gfm-alert-note` would now lose to this base layer and invert the intended
|
|
19
|
+
* base-under-theme layering.
|
|
20
|
+
*
|
|
21
|
+
* `.gfm-alert-title` stays unscoped in both layers on purpose: no theme
|
|
22
|
+
* declares an element-scoped rule that competes with it, so a bare class still
|
|
23
|
+
* lets themes override it by concatenation order.
|
|
24
|
+
*
|
|
25
|
+
* Must never use !important -- themes are layered after this and would lose.
|
|
26
|
+
*/
|
|
27
|
+
export declare const alertsBaseCss = "\n.markdown-body blockquote.gfm-alert {\n margin: 1.2em 0;\n padding: 12px 16px;\n border-left: 4px solid #57606a;\n border-radius: 4px;\n background-color: #f6f8fa;\n}\n\n.markdown-body blockquote.gfm-alert-note { border-left-color: #0969da; background-color: #ddf4ff; }\n.markdown-body blockquote.gfm-alert-tip { border-left-color: #1a7f37; background-color: #dafbe1; }\n.markdown-body blockquote.gfm-alert-important { border-left-color: #8250df; background-color: #fbefff; }\n.markdown-body blockquote.gfm-alert-warning { border-left-color: #9a6700; background-color: #fff8c5; }\n.markdown-body blockquote.gfm-alert-caution { border-left-color: #cf222e; background-color: #ffebe9; }\n\n.gfm-alert-title {\n font-weight: 700;\n margin-bottom: 4px;\n display: flex;\n align-items: center;\n}\n";
|
|
28
|
+
export declare function processGfmAlerts(html: string, enabled?: boolean): string;
|
|
29
|
+
//# sourceMappingURL=alerts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../src/plugins/alerts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,aAAa,wyBAqBzB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAc,GAAG,MAAM,CA8B9E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.alertsBaseCss = void 0;
|
|
4
|
+
exports.processGfmAlerts = processGfmAlerts;
|
|
5
|
+
/**
|
|
6
|
+
* Structural styling for the markup this plugin emits. See the note on
|
|
7
|
+
* codeDecoratorBaseCss about the no-!important rule.
|
|
8
|
+
*
|
|
9
|
+
* The alert selectors are deliberately scoped as
|
|
10
|
+
* `.markdown-body blockquote.gfm-alert-note` (specificity 0,2,1) rather than a
|
|
11
|
+
* bare `.gfm-alert-note` (0,1,0). Every built-in theme declares
|
|
12
|
+
* `.markdown-body blockquote { background-color: ...; border-left: ... }`
|
|
13
|
+
* (0,1,1) -- see themes/tech.ts -- which outranks a bare class regardless of
|
|
14
|
+
* concatenation order and collapsed all five alert types onto one generic
|
|
15
|
+
* blockquote look. (A minimal custom theme that skips blockquote styling
|
|
16
|
+
* entirely wouldn't hit this, but the scoped selector is harmless for it too.)
|
|
17
|
+
* Same defect class as the `img.wm-formula-*` rules; the rationale block in
|
|
18
|
+
* media/styles.ts covers it in full.
|
|
19
|
+
*
|
|
20
|
+
* Consequence for themes: a theme that wants to restyle alerts must match this
|
|
21
|
+
* shape (`.markdown-body blockquote.gfm-alert-note`), because a bare
|
|
22
|
+
* `.gfm-alert-note` would now lose to this base layer and invert the intended
|
|
23
|
+
* base-under-theme layering.
|
|
24
|
+
*
|
|
25
|
+
* `.gfm-alert-title` stays unscoped in both layers on purpose: no theme
|
|
26
|
+
* declares an element-scoped rule that competes with it, so a bare class still
|
|
27
|
+
* lets themes override it by concatenation order.
|
|
28
|
+
*
|
|
29
|
+
* Must never use !important -- themes are layered after this and would lose.
|
|
30
|
+
*/
|
|
31
|
+
exports.alertsBaseCss = `
|
|
32
|
+
.markdown-body blockquote.gfm-alert {
|
|
33
|
+
margin: 1.2em 0;
|
|
34
|
+
padding: 12px 16px;
|
|
35
|
+
border-left: 4px solid #57606a;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
background-color: #f6f8fa;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.markdown-body blockquote.gfm-alert-note { border-left-color: #0969da; background-color: #ddf4ff; }
|
|
41
|
+
.markdown-body blockquote.gfm-alert-tip { border-left-color: #1a7f37; background-color: #dafbe1; }
|
|
42
|
+
.markdown-body blockquote.gfm-alert-important { border-left-color: #8250df; background-color: #fbefff; }
|
|
43
|
+
.markdown-body blockquote.gfm-alert-warning { border-left-color: #9a6700; background-color: #fff8c5; }
|
|
44
|
+
.markdown-body blockquote.gfm-alert-caution { border-left-color: #cf222e; background-color: #ffebe9; }
|
|
45
|
+
|
|
46
|
+
.gfm-alert-title {
|
|
47
|
+
font-weight: 700;
|
|
48
|
+
margin-bottom: 4px;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
function processGfmAlerts(html, enabled = true) {
|
|
54
|
+
if (!enabled) {
|
|
55
|
+
return html;
|
|
56
|
+
}
|
|
57
|
+
const alertTypes = {
|
|
58
|
+
NOTE: { label: 'Note', icon: 'ℹ️' },
|
|
59
|
+
TIP: { label: 'Tip', icon: '💡' },
|
|
60
|
+
IMPORTANT: { label: 'Important', icon: '📌' },
|
|
61
|
+
WARNING: { label: 'Warning', icon: '⚠️' },
|
|
62
|
+
CAUTION: { label: 'Caution', icon: '🛑' },
|
|
63
|
+
};
|
|
64
|
+
// Matches blockquotes containing [!NOTE], [!TIP], etc.
|
|
65
|
+
const blockquoteRegex = /<blockquote>\s*<p>\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*([\s\S]*?)<\/p>([\s\S]*?)<\/blockquote>/gi;
|
|
66
|
+
return html.replace(blockquoteRegex, (match, typeUpper, firstLineText, restContent) => {
|
|
67
|
+
const type = typeUpper.toUpperCase();
|
|
68
|
+
const config = alertTypes[type] || { label: type, icon: '🔔' };
|
|
69
|
+
const alertClass = `gfm-alert gfm-alert-${type.toLowerCase()}`;
|
|
70
|
+
const content = `<p>${firstLineText}</p>${restContent}`.trim();
|
|
71
|
+
return `
|
|
72
|
+
<blockquote class="${alertClass}">
|
|
73
|
+
<div class="gfm-alert-title">${config.icon} ${config.label}</div>
|
|
74
|
+
${content}
|
|
75
|
+
</blockquote>
|
|
76
|
+
`.trim();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=alerts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.js","sourceRoot":"","sources":["../../src/plugins/alerts.ts"],"names":[],"mappings":";;;AAiDA,4CA8BC;AA/ED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB5B,CAAC;AAEF,SAAgB,gBAAgB,CAAC,IAAY,EAAE,UAAmB,IAAI;IACpE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAoD;QAClE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;QACnC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE;QACjC,SAAS,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE;QAC7C,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE;QACzC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE;KAC1C,CAAC;IAEF,uDAAuD;IACvD,MAAM,eAAe,GAAG,yGAAyG,CAAC;IAElI,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACpF,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/D,MAAM,UAAU,GAAG,uBAAuB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QAE/D,MAAM,OAAO,GAAG,MAAM,aAAa,OAAO,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAE/D,OAAO;qBACU,UAAU;iCACE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK;IACxD,OAAO;;CAEV,CAAC,IAAI,EAAE,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural styling for the markup this plugin emits, in neutral colors.
|
|
3
|
+
* Ships with the capability so a theme only has to supply brand overrides.
|
|
4
|
+
* Must never use !important -- themes are layered after this and would lose.
|
|
5
|
+
*/
|
|
6
|
+
export declare const codeDecoratorBaseCss = "\n.mac-code-wrapper {\n margin: 1.2em 0;\n border-radius: 6px;\n overflow: hidden;\n background-color: #282c34;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n}\n\n.mac-code-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 14px;\n background-color: #21252b;\n border-bottom: 1px solid #181a1f;\n}\n\n.mac-dots {\n display: flex;\n gap: 6px;\n}\n\n.mac-dot {\n width: 10px;\n height: 10px;\n border-radius: 50%;\n}\n\n.mac-dot-red { background-color: #ff5f56; }\n.mac-dot-yellow { background-color: #ffbd2e; }\n.mac-dot-green { background-color: #27c93f; }\n\n.mac-code-lang {\n font-size: 11px;\n color: #7f848e;\n text-transform: uppercase;\n font-family: Menlo, Monaco, Consolas, monospace;\n}\n";
|
|
7
|
+
export declare function decorateCodeBlocks(html: string, enabled?: boolean): string;
|
|
8
|
+
//# sourceMappingURL=code-decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-decorator.d.ts","sourceRoot":"","sources":["../../src/plugins/code-decorator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,mwBAuChC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAc,GAAG,MAAM,CAwBhF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codeDecoratorBaseCss = void 0;
|
|
4
|
+
exports.decorateCodeBlocks = decorateCodeBlocks;
|
|
5
|
+
/**
|
|
6
|
+
* Structural styling for the markup this plugin emits, in neutral colors.
|
|
7
|
+
* Ships with the capability so a theme only has to supply brand overrides.
|
|
8
|
+
* Must never use !important -- themes are layered after this and would lose.
|
|
9
|
+
*/
|
|
10
|
+
exports.codeDecoratorBaseCss = `
|
|
11
|
+
.mac-code-wrapper {
|
|
12
|
+
margin: 1.2em 0;
|
|
13
|
+
border-radius: 6px;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
background-color: #282c34;
|
|
16
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.mac-code-header {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
padding: 8px 14px;
|
|
24
|
+
background-color: #21252b;
|
|
25
|
+
border-bottom: 1px solid #181a1f;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.mac-dots {
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: 6px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.mac-dot {
|
|
34
|
+
width: 10px;
|
|
35
|
+
height: 10px;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.mac-dot-red { background-color: #ff5f56; }
|
|
40
|
+
.mac-dot-yellow { background-color: #ffbd2e; }
|
|
41
|
+
.mac-dot-green { background-color: #27c93f; }
|
|
42
|
+
|
|
43
|
+
.mac-code-lang {
|
|
44
|
+
font-size: 11px;
|
|
45
|
+
color: #7f848e;
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
font-family: Menlo, Monaco, Consolas, monospace;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
function decorateCodeBlocks(html, enabled = true) {
|
|
51
|
+
if (!enabled) {
|
|
52
|
+
return html;
|
|
53
|
+
}
|
|
54
|
+
// Regex to match <pre><code( class="language-xxx")?>...</code></pre>
|
|
55
|
+
const preRegex = /<pre><code(?:\s+class="language-([^"]+)")?>([\s\S]*?)<\/code><\/pre>/g;
|
|
56
|
+
return html.replace(preRegex, (match, lang, codeContent) => {
|
|
57
|
+
const displayLang = lang ? lang.toUpperCase() : 'CODE';
|
|
58
|
+
return `
|
|
59
|
+
<section class="mac-code-wrapper">
|
|
60
|
+
<section class="mac-code-header">
|
|
61
|
+
<section class="mac-dots">
|
|
62
|
+
<span class="mac-dot mac-dot-red"></span>
|
|
63
|
+
<span class="mac-dot mac-dot-yellow"></span>
|
|
64
|
+
<span class="mac-dot mac-dot-green"></span>
|
|
65
|
+
</section>
|
|
66
|
+
<span class="mac-code-lang">${displayLang}</span>
|
|
67
|
+
</section>
|
|
68
|
+
<pre><code>${codeContent}</code></pre>
|
|
69
|
+
</section>
|
|
70
|
+
`.trim();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=code-decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-decorator.js","sourceRoot":"","sources":["../../src/plugins/code-decorator.ts"],"names":[],"mappings":";;;AA8CA,gDAwBC;AAtED;;;;GAIG;AACU,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCnC,CAAC;AAEF,SAAgB,kBAAkB,CAAC,IAAY,EAAE,UAAmB,IAAI;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qEAAqE;IACrE,MAAM,QAAQ,GAAG,uEAAuE,CAAC;IAEzF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;QACzD,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACvD,OAAO;;;;;;;;kCAQuB,WAAW;;eAE9B,WAAW;;CAEzB,CAAC,IAAI,EAAE,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FootnoteItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Structural styling for the markup this plugin emits. See the note on
|
|
4
|
+
* codeDecoratorBaseCss about the no-!important rule.
|
|
5
|
+
*
|
|
6
|
+
* #576b95 is WeChat's own in-article link color, matching what the WeChat
|
|
7
|
+
* editor renders for neutered links.
|
|
8
|
+
*/
|
|
9
|
+
export declare const footnotesBaseCss = "\n.footnote-ref {\n color: #57606a;\n font-size: 0.8em;\n vertical-align: super;\n text-decoration: none;\n font-weight: 600;\n padding: 0 2px;\n}\n\n.footnotes-container {\n margin-top: 2.5em;\n padding-top: 1.2em;\n border-top: 1px dashed #d0d7de;\n font-size: 0.85em;\n color: #666666;\n}\n\n.footnotes-title {\n font-size: 1.05em;\n font-weight: 700;\n color: #57606a;\n margin-bottom: 0.8em;\n}\n\n.footnote-item {\n margin: 0.4em 0;\n word-break: break-all;\n}\n\n.footnote-url {\n color: #576b95;\n text-decoration: underline;\n}\n";
|
|
10
|
+
export interface ProcessFootnotesResult {
|
|
11
|
+
markdown: string;
|
|
12
|
+
footnotes: FootnoteItem[];
|
|
13
|
+
}
|
|
14
|
+
export declare function processMarkdownFootnotes(markdown: string, siteUrl?: string): ProcessFootnotesResult;
|
|
15
|
+
export declare function renderFootnotesHtml(footnotes: FootnoteItem[]): string;
|
|
16
|
+
//# sourceMappingURL=footnotes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../../src/plugins/footnotes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,kjBAkC5B,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,sBAAsB,CA4CnG;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,MAAM,CAiBrE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.footnotesBaseCss = void 0;
|
|
4
|
+
exports.processMarkdownFootnotes = processMarkdownFootnotes;
|
|
5
|
+
exports.renderFootnotesHtml = renderFootnotesHtml;
|
|
6
|
+
/**
|
|
7
|
+
* Structural styling for the markup this plugin emits. See the note on
|
|
8
|
+
* codeDecoratorBaseCss about the no-!important rule.
|
|
9
|
+
*
|
|
10
|
+
* #576b95 is WeChat's own in-article link color, matching what the WeChat
|
|
11
|
+
* editor renders for neutered links.
|
|
12
|
+
*/
|
|
13
|
+
exports.footnotesBaseCss = `
|
|
14
|
+
.footnote-ref {
|
|
15
|
+
color: #57606a;
|
|
16
|
+
font-size: 0.8em;
|
|
17
|
+
vertical-align: super;
|
|
18
|
+
text-decoration: none;
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
padding: 0 2px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.footnotes-container {
|
|
24
|
+
margin-top: 2.5em;
|
|
25
|
+
padding-top: 1.2em;
|
|
26
|
+
border-top: 1px dashed #d0d7de;
|
|
27
|
+
font-size: 0.85em;
|
|
28
|
+
color: #666666;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.footnotes-title {
|
|
32
|
+
font-size: 1.05em;
|
|
33
|
+
font-weight: 700;
|
|
34
|
+
color: #57606a;
|
|
35
|
+
margin-bottom: 0.8em;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.footnote-item {
|
|
39
|
+
margin: 0.4em 0;
|
|
40
|
+
word-break: break-all;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.footnote-url {
|
|
44
|
+
color: #576b95;
|
|
45
|
+
text-decoration: underline;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
function processMarkdownFootnotes(markdown, siteUrl) {
|
|
49
|
+
const footnotes = [];
|
|
50
|
+
const urlMap = new Map();
|
|
51
|
+
// Helper to normalize URL
|
|
52
|
+
const isExternalUrl = (url) => {
|
|
53
|
+
if (url.startsWith('#') || url.startsWith('javascript:') || url.startsWith('mailto:')) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (siteUrl && url.startsWith(siteUrl)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (url.startsWith('/') && !url.startsWith('//')) {
|
|
60
|
+
return false; // local relative path
|
|
61
|
+
}
|
|
62
|
+
return /^https?:\/\//i.test(url);
|
|
63
|
+
};
|
|
64
|
+
// Match Markdown links: [text](url) - ignore images 
|
|
65
|
+
const linkRegex = /(?<!!)\[([^\]]+)\]\((https?:\/\/[^\s)]+)(?:\s+"[^"]*")?\)/g;
|
|
66
|
+
const transformedMarkdown = markdown.replace(linkRegex, (match, text, url) => {
|
|
67
|
+
if (!isExternalUrl(url)) {
|
|
68
|
+
return match;
|
|
69
|
+
}
|
|
70
|
+
let index = urlMap.get(url);
|
|
71
|
+
if (!index) {
|
|
72
|
+
index = footnotes.length + 1;
|
|
73
|
+
urlMap.set(url, index);
|
|
74
|
+
footnotes.push({
|
|
75
|
+
index,
|
|
76
|
+
title: text.trim(),
|
|
77
|
+
url: url.trim(),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return `${text}<sup class="footnote-ref">[${index}]</sup>`;
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
markdown: transformedMarkdown,
|
|
84
|
+
footnotes,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function renderFootnotesHtml(footnotes) {
|
|
88
|
+
if (footnotes.length === 0) {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
const itemsHtml = footnotes
|
|
92
|
+
.map((item) => {
|
|
93
|
+
return `<p class="footnote-item"><strong>[${item.index}]</strong> ${item.title}: <span class="footnote-url">${item.url}</span></p>`;
|
|
94
|
+
})
|
|
95
|
+
.join('\n');
|
|
96
|
+
return `
|
|
97
|
+
<section class="footnotes-container">
|
|
98
|
+
<div class="footnotes-title">📚 参考链接</div>
|
|
99
|
+
${itemsHtml}
|
|
100
|
+
</section>
|
|
101
|
+
`.trim();
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=footnotes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footnotes.js","sourceRoot":"","sources":["../../src/plugins/footnotes.ts"],"names":[],"mappings":";;;AAkDA,4DA4CC;AAED,kDAiBC;AA/GD;;;;;;GAMG;AACU,QAAA,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC/B,CAAC;AAOF,SAAgB,wBAAwB,CAAC,QAAgB,EAAE,OAAgB;IACzE,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,0BAA0B;IAC1B,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;QAC7C,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACtF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACjD,OAAO,KAAK,CAAC,CAAC,sBAAsB;QACtC,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,gEAAgE;IAChE,MAAM,SAAS,GAAG,4DAA4D,CAAC;IAE/E,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC3E,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACvB,SAAS,CAAC,IAAI,CAAC;gBACb,KAAK;gBACL,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE;gBAClB,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;aAChB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,GAAG,IAAI,8BAA8B,KAAK,SAAS,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,mBAAmB;QAC7B,SAAS;KACV,CAAC;AACJ,CAAC;AAED,SAAgB,mBAAmB,CAAC,SAAyB;IAC3D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,SAAS;SACxB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,qCAAqC,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,gCAAgC,IAAI,CAAC,GAAG,aAAa,CAAC;IACtI,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;IAGL,SAAS;;CAEZ,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural styling for the markup this plugin emits. See the note on
|
|
3
|
+
* codeDecoratorBaseCss about the no-!important rule.
|
|
4
|
+
*/
|
|
5
|
+
export declare const tableScrollerBaseCss = "\n.table-scroller {\n overflow-x: auto;\n -webkit-overflow-scrolling: touch;\n margin: 1.2em 0;\n}\n";
|
|
6
|
+
export declare function wrapTablesWithScroller(html: string, enabled?: boolean): string;
|
|
7
|
+
//# sourceMappingURL=table-scroller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-scroller.d.ts","sourceRoot":"","sources":["../../src/plugins/table-scroller.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,4GAMhC,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAc,GAAG,MAAM,CAQpF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableScrollerBaseCss = void 0;
|
|
4
|
+
exports.wrapTablesWithScroller = wrapTablesWithScroller;
|
|
5
|
+
/**
|
|
6
|
+
* Structural styling for the markup this plugin emits. See the note on
|
|
7
|
+
* codeDecoratorBaseCss about the no-!important rule.
|
|
8
|
+
*/
|
|
9
|
+
exports.tableScrollerBaseCss = `
|
|
10
|
+
.table-scroller {
|
|
11
|
+
overflow-x: auto;
|
|
12
|
+
-webkit-overflow-scrolling: touch;
|
|
13
|
+
margin: 1.2em 0;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
function wrapTablesWithScroller(html, enabled = true) {
|
|
17
|
+
if (!enabled) {
|
|
18
|
+
return html;
|
|
19
|
+
}
|
|
20
|
+
return html.replace(/<table(\s+[^>]*)?>([\s\S]*?)<\/table>/g, (match) => {
|
|
21
|
+
return `<section class="table-scroller">${match}</section>`;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=table-scroller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-scroller.js","sourceRoot":"","sources":["../../src/plugins/table-scroller.ts"],"names":[],"mappings":";;;AAYA,wDAQC;AApBD;;;GAGG;AACU,QAAA,oBAAoB,GAAG;;;;;;CAMnC,CAAC;AAEF,SAAgB,sBAAsB,CAAC,IAAY,EAAE,UAAmB,IAAI;IAC1E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,wCAAwC,EAAE,CAAC,KAAK,EAAE,EAAE;QACtE,OAAO,mCAAmC,KAAK,YAAY,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC"}
|