@memberjunction/markdown-core 0.0.0 → 5.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/markdown-engine.d.ts +109 -0
- package/dist/engine/markdown-engine.d.ts.map +1 -0
- package/dist/engine/markdown-engine.js +292 -0
- package/dist/engine/markdown-engine.js.map +1 -0
- package/dist/extensions/collapsible-headings.extension.d.ts +62 -0
- package/dist/extensions/collapsible-headings.extension.d.ts.map +1 -0
- package/dist/extensions/collapsible-headings.extension.js +174 -0
- package/dist/extensions/collapsible-headings.extension.js.map +1 -0
- package/dist/extensions/html-block-repair.extension.d.ts +24 -0
- package/dist/extensions/html-block-repair.extension.d.ts.map +1 -0
- package/dist/extensions/html-block-repair.extension.js +47 -0
- package/dist/extensions/html-block-repair.extension.js.map +1 -0
- package/dist/extensions/svg-renderer.extension.d.ts +58 -0
- package/dist/extensions/svg-renderer.extension.d.ts.map +1 -0
- package/dist/extensions/svg-renderer.extension.js +83 -0
- package/dist/extensions/svg-renderer.extension.js.map +1 -0
- package/dist/helpers/escape.d.ts +9 -0
- package/dist/helpers/escape.d.ts.map +1 -0
- package/dist/helpers/escape.js +16 -0
- package/dist/helpers/escape.js.map +1 -0
- package/dist/helpers/language.d.ts +14 -0
- package/dist/helpers/language.d.ts.map +1 -0
- package/dist/helpers/language.js +68 -0
- package/dist/helpers/language.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/types/markdown.types.d.ts +213 -0
- package/dist/types/markdown.types.d.ts.map +1 -0
- package/dist/types/markdown.types.js +25 -0
- package/dist/types/markdown.types.js.map +1 -0
- package/package.json +37 -6
- package/README.md +0 -45
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapsible-headings.extension.js","sourceRoot":"","sources":["../../src/extensions/collapsible-headings.extension.ts"],"names":[],"mappings":"AAwCA,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,IAAI,CAAC,WAAW,WAAW,aAAa,iBAAiB,KAAK,IAAI,CAAC,CAAC;YAC/F,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,WAAW,oBAAoB,CAAC,CAAC;YACjE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,WAAW,YAAY,CAAC,CAAC;YAEzD,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,YAAY,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MarkedExtension } from 'marked';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a marked extension that repairs HTML blocks split by a blank line.
|
|
4
|
+
*
|
|
5
|
+
* Raw HTML embedded in markdown (e.g. a Skip PRD "## Mockup" section) is meant
|
|
6
|
+
* to be a single HTML block, but CommonMark ends an HTML block at the first
|
|
7
|
+
* blank line. Any following indented (4+ space) markup is then tokenized as an
|
|
8
|
+
* indented code block and rendered as escaped text — a "black box" of raw
|
|
9
|
+
* markup instead of the intended HTML.
|
|
10
|
+
*
|
|
11
|
+
* This hook detects that case in the token stream and reclassifies the
|
|
12
|
+
* misparsed code token back to an html token so it renders. To stay precise it
|
|
13
|
+
* only fires when the code token is ALL of:
|
|
14
|
+
* - an indented code block (no `lang` → not a fenced ``` example),
|
|
15
|
+
* - whose content starts with an HTML tag or comment, and
|
|
16
|
+
* - directly adjacent to an `html` token (the signature of a split block).
|
|
17
|
+
* Prose, fenced code examples, and standalone indented code are left untouched.
|
|
18
|
+
*
|
|
19
|
+
* Pure token-stream logic — no DOM dependency — so it lives in the
|
|
20
|
+
* framework-agnostic core engine and benefits both the web (HTML) and native
|
|
21
|
+
* (AST) output paths.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createHtmlBlockRepairExtension(): MarkedExtension;
|
|
24
|
+
//# sourceMappingURL=html-block-repair.extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-block-repair.extension.d.ts","sourceRoot":"","sources":["../../src/extensions/html-block-repair.extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiB,MAAM,QAAQ,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,8BAA8B,IAAI,eAAe,CAuBhE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a marked extension that repairs HTML blocks split by a blank line.
|
|
3
|
+
*
|
|
4
|
+
* Raw HTML embedded in markdown (e.g. a Skip PRD "## Mockup" section) is meant
|
|
5
|
+
* to be a single HTML block, but CommonMark ends an HTML block at the first
|
|
6
|
+
* blank line. Any following indented (4+ space) markup is then tokenized as an
|
|
7
|
+
* indented code block and rendered as escaped text — a "black box" of raw
|
|
8
|
+
* markup instead of the intended HTML.
|
|
9
|
+
*
|
|
10
|
+
* This hook detects that case in the token stream and reclassifies the
|
|
11
|
+
* misparsed code token back to an html token so it renders. To stay precise it
|
|
12
|
+
* only fires when the code token is ALL of:
|
|
13
|
+
* - an indented code block (no `lang` → not a fenced ``` example),
|
|
14
|
+
* - whose content starts with an HTML tag or comment, and
|
|
15
|
+
* - directly adjacent to an `html` token (the signature of a split block).
|
|
16
|
+
* Prose, fenced code examples, and standalone indented code are left untouched.
|
|
17
|
+
*
|
|
18
|
+
* Pure token-stream logic — no DOM dependency — so it lives in the
|
|
19
|
+
* framework-agnostic core engine and benefits both the web (HTML) and native
|
|
20
|
+
* (AST) output paths.
|
|
21
|
+
*/
|
|
22
|
+
export function createHtmlBlockRepairExtension() {
|
|
23
|
+
const looksLikeHtml = (text) => /^\s*<\/?[a-zA-Z!]/.test(text || '');
|
|
24
|
+
return {
|
|
25
|
+
hooks: {
|
|
26
|
+
processAllTokens(tokens) {
|
|
27
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
28
|
+
const token = tokens[i];
|
|
29
|
+
if (token.type !== 'code')
|
|
30
|
+
continue;
|
|
31
|
+
const code = token;
|
|
32
|
+
if (code.lang || !looksLikeHtml(code.text))
|
|
33
|
+
continue;
|
|
34
|
+
const prev = tokens[i - 1];
|
|
35
|
+
const next = tokens[i + 1];
|
|
36
|
+
if (prev?.type === 'html' || next?.type === 'html') {
|
|
37
|
+
// Reclassify as a raw HTML block so the html renderer emits it verbatim.
|
|
38
|
+
const html = { type: 'html', raw: code.raw, pre: false, text: code.text, block: true };
|
|
39
|
+
tokens[i] = html;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return tokens;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=html-block-repair.extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-block-repair.extension.js","sourceRoot":"","sources":["../../src/extensions/html-block-repair.extension.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACtF,OAAO;QACL,KAAK,EAAE;YACL,gBAAgB,CAAC,MAAe;gBAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACvC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;oBACxB,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;wBAAE,SAAS;oBACpC,MAAM,IAAI,GAAG,KAAoB,CAAC;oBAClC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;wBAAE,SAAS;oBAErD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3B,IAAI,IAAI,EAAE,IAAI,KAAK,MAAM,IAAI,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;wBACnD,yEAAyE;wBACzE,MAAM,IAAI,GAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;wBACpG,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;oBACnB,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { MarkedExtension, Tokens } from 'marked';
|
|
2
|
+
/**
|
|
3
|
+
* The custom token emitted by the SVG renderer extension for a ```svg fence.
|
|
4
|
+
*
|
|
5
|
+
* This is the framework-agnostic hand-off: the web/HTML path renders it into a
|
|
6
|
+
* `.svg-rendered` wrapper, while a native path (React Native + react-native-svg)
|
|
7
|
+
* can consume {@link svgContent} directly.
|
|
8
|
+
*/
|
|
9
|
+
export interface SvgCodeBlockToken extends Tokens.Generic {
|
|
10
|
+
/** Discriminant identifying this custom block token. */
|
|
11
|
+
type: 'svgCodeBlock';
|
|
12
|
+
/** The original matched markdown source (the full ```svg … ``` fence). */
|
|
13
|
+
raw: string;
|
|
14
|
+
/** The inner SVG markup, trimmed — everything between the fences. */
|
|
15
|
+
svgContent: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a marked extension that renders SVG code blocks as actual SVG images.
|
|
19
|
+
*
|
|
20
|
+
* When encountering a code block with language "svg", this extension will
|
|
21
|
+
* render it as an actual SVG element instead of showing the code.
|
|
22
|
+
*
|
|
23
|
+
* This is useful for:
|
|
24
|
+
* - UX mockups and wireframes
|
|
25
|
+
* - Diagrams and illustrations
|
|
26
|
+
* - Icons and simple graphics
|
|
27
|
+
* - Any visual content that can be expressed as SVG
|
|
28
|
+
*
|
|
29
|
+
* Usage in markdown:
|
|
30
|
+
* ```svg
|
|
31
|
+
* <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
|
|
32
|
+
* <circle cx="50" cy="50" r="40" fill="blue"/>
|
|
33
|
+
* </svg>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* The generated HTML structure:
|
|
37
|
+
* ```html
|
|
38
|
+
* <div class="svg-rendered">
|
|
39
|
+
* <svg ...>...</svg>
|
|
40
|
+
* </div>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* The tokenizer is framework-agnostic — it emits an `svgCodeBlock` token whose
|
|
44
|
+
* `svgContent` can be rendered to HTML (web) or to a native SVG component
|
|
45
|
+
* (React Native via react-native-svg). The HTML `renderer` below is only used
|
|
46
|
+
* by the web/HTML output path.
|
|
47
|
+
*
|
|
48
|
+
* Security note: SVG content is rendered as-is. Make sure to only render
|
|
49
|
+
* trusted SVG content or sanitize it on the target platform when rendering
|
|
50
|
+
* user-provided content.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createSvgRendererExtension(): MarkedExtension;
|
|
53
|
+
/**
|
|
54
|
+
* Basic validation to check if content appears to be SVG.
|
|
55
|
+
* This is a simple check - it doesn't fully validate SVG syntax.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isSvgContent(content: string): boolean;
|
|
58
|
+
//# sourceMappingURL=svg-renderer.extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-renderer.extension.d.ts","sourceRoot":"","sources":["../../src/extensions/svg-renderer.extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,MAAM,CAAC,OAAO;IACvD,wDAAwD;IACxD,IAAI,EAAE,cAAc,CAAC;IACrB,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,0BAA0B,IAAI,eAAe,CAoC5D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASrD"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a marked extension that renders SVG code blocks as actual SVG images.
|
|
3
|
+
*
|
|
4
|
+
* When encountering a code block with language "svg", this extension will
|
|
5
|
+
* render it as an actual SVG element instead of showing the code.
|
|
6
|
+
*
|
|
7
|
+
* This is useful for:
|
|
8
|
+
* - UX mockups and wireframes
|
|
9
|
+
* - Diagrams and illustrations
|
|
10
|
+
* - Icons and simple graphics
|
|
11
|
+
* - Any visual content that can be expressed as SVG
|
|
12
|
+
*
|
|
13
|
+
* Usage in markdown:
|
|
14
|
+
* ```svg
|
|
15
|
+
* <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
* <circle cx="50" cy="50" r="40" fill="blue"/>
|
|
17
|
+
* </svg>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* The generated HTML structure:
|
|
21
|
+
* ```html
|
|
22
|
+
* <div class="svg-rendered">
|
|
23
|
+
* <svg ...>...</svg>
|
|
24
|
+
* </div>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The tokenizer is framework-agnostic — it emits an `svgCodeBlock` token whose
|
|
28
|
+
* `svgContent` can be rendered to HTML (web) or to a native SVG component
|
|
29
|
+
* (React Native via react-native-svg). The HTML `renderer` below is only used
|
|
30
|
+
* by the web/HTML output path.
|
|
31
|
+
*
|
|
32
|
+
* Security note: SVG content is rendered as-is. Make sure to only render
|
|
33
|
+
* trusted SVG content or sanitize it on the target platform when rendering
|
|
34
|
+
* user-provided content.
|
|
35
|
+
*/
|
|
36
|
+
export function createSvgRendererExtension() {
|
|
37
|
+
return {
|
|
38
|
+
extensions: [{
|
|
39
|
+
name: 'svgCodeBlock',
|
|
40
|
+
level: 'block',
|
|
41
|
+
start(src) {
|
|
42
|
+
// Look for ```svg at the start of the source
|
|
43
|
+
const match = src.match(/^```svg\b/);
|
|
44
|
+
return match ? match.index : undefined;
|
|
45
|
+
},
|
|
46
|
+
tokenizer(src) {
|
|
47
|
+
// Match ```svg code blocks
|
|
48
|
+
const rule = /^```svg\n([\s\S]*?)```(?:\n|$)/;
|
|
49
|
+
const match = rule.exec(src);
|
|
50
|
+
if (match) {
|
|
51
|
+
const svgContent = match[1].trim();
|
|
52
|
+
// Only process if it looks like valid SVG
|
|
53
|
+
if (isSvgContent(svgContent)) {
|
|
54
|
+
const token = {
|
|
55
|
+
type: 'svgCodeBlock',
|
|
56
|
+
raw: match[0],
|
|
57
|
+
svgContent
|
|
58
|
+
};
|
|
59
|
+
return token;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
},
|
|
64
|
+
renderer(token) {
|
|
65
|
+
const svgToken = token;
|
|
66
|
+
return `<div class="svg-rendered">${svgToken.svgContent}</div>\n`;
|
|
67
|
+
}
|
|
68
|
+
}]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Basic validation to check if content appears to be SVG.
|
|
73
|
+
* This is a simple check - it doesn't fully validate SVG syntax.
|
|
74
|
+
*/
|
|
75
|
+
export function isSvgContent(content) {
|
|
76
|
+
// Check if it starts with <svg and contains closing </svg>
|
|
77
|
+
const startsWithSvg = content.toLowerCase().startsWith('<svg');
|
|
78
|
+
const hasSvgClosing = content.toLowerCase().includes('</svg>');
|
|
79
|
+
// Also accept self-closing SVG (rare but valid)
|
|
80
|
+
const isSelfClosing = content.toLowerCase().match(/<svg[^>]*\/>/);
|
|
81
|
+
return (startsWithSvg && hasSvgClosing) || !!isSelfClosing;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=svg-renderer.extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-renderer.extension.js","sourceRoot":"","sources":["../../src/extensions/svg-renderer.extension.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,UAAU,EAAE,CAAC;gBACX,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,OAAO;gBACd,KAAK,CAAC,GAAW;oBACf,6CAA6C;oBAC7C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;oBACrC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACzC,CAAC;gBACD,SAAS,CAAC,GAAW;oBACnB,2BAA2B;oBAC3B,MAAM,IAAI,GAAG,gCAAgC,CAAC;oBAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAE7B,IAAI,KAAK,EAAE,CAAC;wBACV,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;wBAEnC,0CAA0C;wBAC1C,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC7B,MAAM,KAAK,GAAsB;gCAC/B,IAAI,EAAE,cAAc;gCACpB,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;gCACb,UAAU;6BACX,CAAC;4BACF,OAAO,KAAK,CAAC;wBACf,CAAC;oBACH,CAAC;oBACD,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,QAAQ,CAAC,KAAK;oBACZ,MAAM,QAAQ,GAAG,KAA0B,CAAC;oBAC5C,OAAO,6BAA6B,QAAQ,CAAC,UAAU,UAAU,CAAC;gBACpE,CAAC;aACF,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,2DAA2D;IAC3D,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE/D,gDAAgD;IAChD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAElE,OAAO,CAAC,aAAa,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape HTML entities for safe display.
|
|
3
|
+
*
|
|
4
|
+
* Pure string implementation (no `document.createElement`) so it works in
|
|
5
|
+
* Node, React Native, and the browser. Used as the fallback when parsing
|
|
6
|
+
* throws — the raw markdown is shown escaped inside a <pre>.
|
|
7
|
+
*/
|
|
8
|
+
export declare function escapeHtml(text: string): string;
|
|
9
|
+
//# sourceMappingURL=escape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/helpers/escape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape HTML entities for safe display.
|
|
3
|
+
*
|
|
4
|
+
* Pure string implementation (no `document.createElement`) so it works in
|
|
5
|
+
* Node, React Native, and the browser. Used as the fallback when parsing
|
|
6
|
+
* throws — the raw markdown is shown escaped inside a <pre>.
|
|
7
|
+
*/
|
|
8
|
+
export function escapeHtml(text) {
|
|
9
|
+
return text
|
|
10
|
+
.replace(/&/g, '&')
|
|
11
|
+
.replace(/</g, '<')
|
|
12
|
+
.replace(/>/g, '>')
|
|
13
|
+
.replace(/"/g, '"')
|
|
14
|
+
.replace(/'/g, ''');
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=escape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/helpers/escape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a language identifier for display (e.g. "ts" -> "TypeScript").
|
|
3
|
+
*
|
|
4
|
+
* Pure string mapping with no DOM dependency, shared by the web copy-button
|
|
5
|
+
* toolbar and the React Native code-block header. Lookup is case-insensitive and
|
|
6
|
+
* collapses aliases to one canonical label (e.g. `js`/`javascript` → `JavaScript`,
|
|
7
|
+
* `yml`/`yaml` → `YAML`).
|
|
8
|
+
*
|
|
9
|
+
* @param language The raw language id from a fenced code block (any casing).
|
|
10
|
+
* @returns The display name for a known language, or — for an unknown id — the
|
|
11
|
+
* input uppercased as a reasonable fallback (an empty string maps to `''`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatLanguageName(language: string): string;
|
|
14
|
+
//# sourceMappingURL=language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/helpers/language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuD3D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a language identifier for display (e.g. "ts" -> "TypeScript").
|
|
3
|
+
*
|
|
4
|
+
* Pure string mapping with no DOM dependency, shared by the web copy-button
|
|
5
|
+
* toolbar and the React Native code-block header. Lookup is case-insensitive and
|
|
6
|
+
* collapses aliases to one canonical label (e.g. `js`/`javascript` → `JavaScript`,
|
|
7
|
+
* `yml`/`yaml` → `YAML`).
|
|
8
|
+
*
|
|
9
|
+
* @param language The raw language id from a fenced code block (any casing).
|
|
10
|
+
* @returns The display name for a known language, or — for an unknown id — the
|
|
11
|
+
* input uppercased as a reasonable fallback (an empty string maps to `''`).
|
|
12
|
+
*/
|
|
13
|
+
export function formatLanguageName(language) {
|
|
14
|
+
const languageMap = {
|
|
15
|
+
js: 'JavaScript',
|
|
16
|
+
ts: 'TypeScript',
|
|
17
|
+
javascript: 'JavaScript',
|
|
18
|
+
typescript: 'TypeScript',
|
|
19
|
+
py: 'Python',
|
|
20
|
+
python: 'Python',
|
|
21
|
+
rb: 'Ruby',
|
|
22
|
+
ruby: 'Ruby',
|
|
23
|
+
cs: 'C#',
|
|
24
|
+
csharp: 'C#',
|
|
25
|
+
cpp: 'C++',
|
|
26
|
+
'c++': 'C++',
|
|
27
|
+
html: 'HTML',
|
|
28
|
+
css: 'CSS',
|
|
29
|
+
scss: 'SCSS',
|
|
30
|
+
sass: 'Sass',
|
|
31
|
+
less: 'Less',
|
|
32
|
+
json: 'JSON',
|
|
33
|
+
yaml: 'YAML',
|
|
34
|
+
yml: 'YAML',
|
|
35
|
+
xml: 'XML',
|
|
36
|
+
sql: 'SQL',
|
|
37
|
+
bash: 'Bash',
|
|
38
|
+
shell: 'Shell',
|
|
39
|
+
sh: 'Shell',
|
|
40
|
+
zsh: 'Zsh',
|
|
41
|
+
powershell: 'PowerShell',
|
|
42
|
+
ps1: 'PowerShell',
|
|
43
|
+
md: 'Markdown',
|
|
44
|
+
markdown: 'Markdown',
|
|
45
|
+
graphql: 'GraphQL',
|
|
46
|
+
gql: 'GraphQL',
|
|
47
|
+
java: 'Java',
|
|
48
|
+
kotlin: 'Kotlin',
|
|
49
|
+
swift: 'Swift',
|
|
50
|
+
go: 'Go',
|
|
51
|
+
rust: 'Rust',
|
|
52
|
+
php: 'PHP',
|
|
53
|
+
r: 'R',
|
|
54
|
+
dockerfile: 'Dockerfile',
|
|
55
|
+
docker: 'Docker',
|
|
56
|
+
nginx: 'Nginx',
|
|
57
|
+
apache: 'Apache',
|
|
58
|
+
ini: 'INI',
|
|
59
|
+
toml: 'TOML',
|
|
60
|
+
makefile: 'Makefile',
|
|
61
|
+
diff: 'Diff',
|
|
62
|
+
plaintext: 'Plain Text',
|
|
63
|
+
text: 'Plain Text',
|
|
64
|
+
mermaid: 'Mermaid'
|
|
65
|
+
};
|
|
66
|
+
return languageMap[language.toLowerCase()] || language.toUpperCase();
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/helpers/language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,WAAW,GAA2B;QAC1C,EAAE,EAAE,YAAY;QAChB,EAAE,EAAE,YAAY;QAChB,UAAU,EAAE,YAAY;QACxB,UAAU,EAAE,YAAY;QACx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|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './engine/markdown-engine';
|
|
2
|
+
export * from './extensions/svg-renderer.extension';
|
|
3
|
+
export * from './extensions/collapsible-headings.extension';
|
|
4
|
+
export * from './extensions/html-block-repair.extension';
|
|
5
|
+
export * from './helpers/language';
|
|
6
|
+
export * from './helpers/escape';
|
|
7
|
+
export * from './types/markdown.types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,0BAA0B,CAAC;AAGzC,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AAGzD,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Public API of @memberjunction/markdown-core
|
|
2
|
+
//
|
|
3
|
+
// Framework-agnostic markdown engine + custom extensions. No DOM, Prism, or
|
|
4
|
+
// Mermaid dependency — consumers (ng-markdown on web, the React Native
|
|
5
|
+
// renderer, etc.) inject highlighting and handle presentation.
|
|
6
|
+
// Engine
|
|
7
|
+
export * from './engine/markdown-engine';
|
|
8
|
+
// Extensions (marked configuration building blocks)
|
|
9
|
+
export * from './extensions/svg-renderer.extension';
|
|
10
|
+
export * from './extensions/collapsible-headings.extension';
|
|
11
|
+
export * from './extensions/html-block-repair.extension';
|
|
12
|
+
// Helpers
|
|
13
|
+
export * from './helpers/language';
|
|
14
|
+
export * from './helpers/escape';
|
|
15
|
+
// Types
|
|
16
|
+
export * from './types/markdown.types';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,4EAA4E;AAC5E,uEAAuE;AACvE,+DAA+D;AAE/D,SAAS;AACT,cAAc,0BAA0B,CAAC;AAEzC,oDAAoD;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AAEzD,UAAU;AACV,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,QAAQ;AACR,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for markdown parsing/rendering.
|
|
3
|
+
*
|
|
4
|
+
* This is the framework-agnostic config shared by every consumer of
|
|
5
|
+
* `@memberjunction/markdown-core` — the Angular `ng-markdown` component, the
|
|
6
|
+
* React Native renderer, and any other UI layer. Flags that only affect one
|
|
7
|
+
* rendering target (e.g. `enableMermaid`, `prismTheme`) are still defined here
|
|
8
|
+
* so a single config object can drive all of them; each renderer reads the
|
|
9
|
+
* subset it understands.
|
|
10
|
+
*/
|
|
11
|
+
export interface MarkdownConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Enable syntax highlighting for code blocks.
|
|
14
|
+
* The core does not highlight on its own — the consumer supplies a highlight
|
|
15
|
+
* function (e.g. Prism on web, react-native-syntax-highlighter on mobile).
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
enableHighlight?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Enable Mermaid diagram rendering (web only — requires a browser DOM).
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
enableMermaid?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Enable copy-to-clipboard button on code blocks.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
enableCodeCopy?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Enable collapsible heading sections.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
enableCollapsibleHeadings?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Heading level at which to start collapsing (1-6)
|
|
36
|
+
* Only applies when enableCollapsibleHeadings is true
|
|
37
|
+
* @default 2
|
|
38
|
+
*/
|
|
39
|
+
collapsibleHeadingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
40
|
+
/**
|
|
41
|
+
* Whether collapsible sections should be expanded by default
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
collapsibleDefaultExpanded?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Specify which heading levels should start expanded.
|
|
47
|
+
* Array of heading levels (2-6) that should be expanded by default.
|
|
48
|
+
* Takes precedence over collapsibleDefaultExpanded for specified levels.
|
|
49
|
+
*
|
|
50
|
+
* Examples:
|
|
51
|
+
* - [2] = Only h2 expanded, h3-h6 collapsed
|
|
52
|
+
* - [2, 3] = h2 and h3 expanded, h4-h6 collapsed
|
|
53
|
+
* - [] = All collapsed (same as collapsibleDefaultExpanded: false)
|
|
54
|
+
* - undefined = Uses collapsibleDefaultExpanded for all levels
|
|
55
|
+
*
|
|
56
|
+
* @default undefined (uses collapsibleDefaultExpanded)
|
|
57
|
+
*/
|
|
58
|
+
autoExpandLevels?: number[];
|
|
59
|
+
/**
|
|
60
|
+
* Enable GitHub-style alerts ([!NOTE], [!WARNING], etc.)
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
enableAlerts?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Enable smartypants for typography (curly quotes, em/en dashes, ellipses)
|
|
66
|
+
* Converts:
|
|
67
|
+
* - "quotes" to "curly quotes"
|
|
68
|
+
* - -- to en-dash (–)
|
|
69
|
+
* - --- to em-dash (—)
|
|
70
|
+
* - ... to ellipsis (…)
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
enableSmartypants?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Enable SVG code block rendering
|
|
76
|
+
* When enabled, ```svg code blocks are rendered as actual SVG images
|
|
77
|
+
* @default true
|
|
78
|
+
*/
|
|
79
|
+
enableSvgRenderer?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Enable raw HTML passthrough in markdown content.
|
|
82
|
+
* When enabled, HTML tags in the markdown are rendered as actual HTML
|
|
83
|
+
* instead of being sanitized/stripped.
|
|
84
|
+
*
|
|
85
|
+
* Note: Even with enableHtml=true, scripts and event handlers are stripped
|
|
86
|
+
* unless enableJavaScript is also true.
|
|
87
|
+
*
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
enableHtml?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Enable JavaScript execution in HTML content.
|
|
93
|
+
* When enabled, <script> tags and on* event handlers are allowed.
|
|
94
|
+
*
|
|
95
|
+
* WARNING: This is a major security risk. Only enable for fully trusted content.
|
|
96
|
+
* In most cases, you want enableHtml=true with enableJavaScript=false.
|
|
97
|
+
*
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
enableJavaScript?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Enable GitHub-style heading IDs for anchor links
|
|
103
|
+
* @default true
|
|
104
|
+
*/
|
|
105
|
+
enableHeadingIds?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Prefix for heading IDs to avoid conflicts
|
|
108
|
+
* @default ''
|
|
109
|
+
*/
|
|
110
|
+
headingIdPrefix?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Enable line numbers in code blocks
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
enableLineNumbers?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Custom CSS class to apply to the markdown container
|
|
118
|
+
*/
|
|
119
|
+
containerClass?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Prism.js theme to use (must be loaded in angular.json or via CSS import)
|
|
122
|
+
* Common themes: 'prism', 'prism-dark', 'prism-okaidia', 'prism-tomorrow', 'prism-coy'
|
|
123
|
+
*/
|
|
124
|
+
prismTheme?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Mermaid theme configuration.
|
|
127
|
+
* 'auto' (default) detects light/dark from the document's data-theme attribute
|
|
128
|
+
* and maps to mermaid's 'default' (light) or 'dark' theme accordingly.
|
|
129
|
+
* @default 'auto'
|
|
130
|
+
*/
|
|
131
|
+
mermaidTheme?: 'auto' | 'default' | 'dark' | 'forest' | 'neutral' | 'base';
|
|
132
|
+
/**
|
|
133
|
+
* Whether to sanitize HTML output
|
|
134
|
+
* Set to false only if you trust the markdown source completely
|
|
135
|
+
* @default true
|
|
136
|
+
*/
|
|
137
|
+
sanitize?: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Config with every field resolved except the optional `autoExpandLevels`.
|
|
141
|
+
*/
|
|
142
|
+
export type ResolvedMarkdownConfig = Required<Omit<MarkdownConfig, 'autoExpandLevels'>> & {
|
|
143
|
+
autoExpandLevels?: number[];
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Default configuration values
|
|
147
|
+
*/
|
|
148
|
+
export declare const DEFAULT_MARKDOWN_CONFIG: ResolvedMarkdownConfig;
|
|
149
|
+
/**
|
|
150
|
+
* Event emitted when markdown rendering is complete
|
|
151
|
+
*/
|
|
152
|
+
export interface MarkdownRenderEvent {
|
|
153
|
+
/**
|
|
154
|
+
* The rendered HTML string
|
|
155
|
+
*/
|
|
156
|
+
html: string;
|
|
157
|
+
/**
|
|
158
|
+
* Time taken to render in milliseconds
|
|
159
|
+
*/
|
|
160
|
+
renderTime: number;
|
|
161
|
+
/**
|
|
162
|
+
* Whether mermaid diagrams were rendered
|
|
163
|
+
*/
|
|
164
|
+
hasMermaid: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Whether code blocks were highlighted
|
|
167
|
+
*/
|
|
168
|
+
hasCodeBlocks: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* List of heading IDs generated (for TOC building)
|
|
171
|
+
*/
|
|
172
|
+
headingIds: HeadingInfo[];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Information about a heading in the document
|
|
176
|
+
*/
|
|
177
|
+
export interface HeadingInfo {
|
|
178
|
+
/**
|
|
179
|
+
* The heading ID (for anchor links)
|
|
180
|
+
*/
|
|
181
|
+
id: string;
|
|
182
|
+
/**
|
|
183
|
+
* The heading text content
|
|
184
|
+
*/
|
|
185
|
+
text: string;
|
|
186
|
+
/**
|
|
187
|
+
* The heading level (1-6)
|
|
188
|
+
*/
|
|
189
|
+
level: number;
|
|
190
|
+
/**
|
|
191
|
+
* The raw markdown text
|
|
192
|
+
*/
|
|
193
|
+
raw: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Alert types supported by marked-alert
|
|
197
|
+
*/
|
|
198
|
+
export type AlertType = 'note' | 'tip' | 'important' | 'warning' | 'caution';
|
|
199
|
+
/**
|
|
200
|
+
* Configuration for a custom alert variant
|
|
201
|
+
*/
|
|
202
|
+
export interface AlertVariant {
|
|
203
|
+
type: string;
|
|
204
|
+
icon: string;
|
|
205
|
+
titleClassName?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Signature for a syntax-highlight function injected into the engine.
|
|
209
|
+
* Receives the raw code and language id, returns highlighted markup
|
|
210
|
+
* (HTML string for the web path). The core never highlights on its own.
|
|
211
|
+
*/
|
|
212
|
+
export type HighlightFunction = (code: string, lang: string) => string;
|
|
213
|
+
//# sourceMappingURL=markdown.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.types.d.ts","sourceRoot":"","sources":["../../src/types/markdown.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,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ACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,UAAU,EAAE,WAAW,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration values
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_MARKDOWN_CONFIG = {
|
|
5
|
+
enableHighlight: true,
|
|
6
|
+
enableMermaid: true,
|
|
7
|
+
enableCodeCopy: true,
|
|
8
|
+
enableCollapsibleHeadings: false,
|
|
9
|
+
collapsibleHeadingLevel: 2,
|
|
10
|
+
collapsibleDefaultExpanded: true,
|
|
11
|
+
autoExpandLevels: undefined,
|
|
12
|
+
enableAlerts: true,
|
|
13
|
+
enableSmartypants: true,
|
|
14
|
+
enableSvgRenderer: true,
|
|
15
|
+
enableHtml: false,
|
|
16
|
+
enableJavaScript: false,
|
|
17
|
+
enableHeadingIds: true,
|
|
18
|
+
headingIdPrefix: '',
|
|
19
|
+
enableLineNumbers: false,
|
|
20
|
+
containerClass: '',
|
|
21
|
+
prismTheme: 'prism-okaidia',
|
|
22
|
+
mermaidTheme: 'auto',
|
|
23
|
+
sanitize: true
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=markdown.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.types.js","sourceRoot":"","sources":["../../src/types/markdown.types.ts"],"names":[],"mappings":"AAkKA;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,yBAAyB,EAAE,KAAK;IAChC,uBAAuB,EAAE,CAAC;IAC1B,0BAA0B,EAAE,IAAI;IAChC,gBAAgB,EAAE,SAAS;IAC3B,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,IAAI;IACvB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,eAAe;IAC3B,YAAY,EAAE,MAAM;IACpB,QAAQ,EAAE,IAAI;CACf,CAAC"}
|