vimd 0.3.14 → 0.3.16
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/core/parser/markdown-it-parser.d.ts +2 -0
- package/dist/core/parser/markdown-it-parser.d.ts.map +1 -1
- package/dist/core/parser/markdown-it-parser.js +27 -1
- package/dist/templates/default.html +13 -0
- package/dist/templates/standalone.html +13 -0
- package/dist/themes/styles/dark.css +1 -1
- package/dist/themes/styles/github.css +1 -1
- package/dist/themes/styles/minimal.css +1 -1
- package/dist/themes/styles/technical.css +1 -1
- package/package.json +1 -1
- package/templates/default.html +13 -0
- package/templates/standalone.html +13 -0
|
@@ -10,6 +10,8 @@ export declare class MarkdownItParser implements Parser {
|
|
|
10
10
|
constructor(_mathConfig?: MathConfig);
|
|
11
11
|
/**
|
|
12
12
|
* Convert markdown to HTML.
|
|
13
|
+
* Math blocks ($$...$$) are protected from markdown-it processing
|
|
14
|
+
* to preserve LaTeX syntax (especially backslashes).
|
|
13
15
|
* @param markdown - The markdown content to convert
|
|
14
16
|
* @returns The converted HTML string
|
|
15
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-it-parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser/markdown-it-parser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,MAAM;IAC7C,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,OAAO,CAAC,EAAE,CAAa;gBAEX,WAAW,CAAC,EAAE,UAAU;IA2BpC
|
|
1
|
+
{"version":3,"file":"markdown-it-parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser/markdown-it-parser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,MAAM;IAC7C,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,OAAO,CAAC,EAAE,CAAa;gBAEX,WAAW,CAAC,EAAE,UAAU;IA2BpC;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqC9C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
|
@@ -36,11 +36,37 @@ export class MarkdownItParser {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Convert markdown to HTML.
|
|
39
|
+
* Math blocks ($$...$$) are protected from markdown-it processing
|
|
40
|
+
* to preserve LaTeX syntax (especially backslashes).
|
|
39
41
|
* @param markdown - The markdown content to convert
|
|
40
42
|
* @returns The converted HTML string
|
|
41
43
|
*/
|
|
42
44
|
async parse(markdown) {
|
|
43
|
-
|
|
45
|
+
// Protect math blocks from markdown-it processing
|
|
46
|
+
const mathBlocks = [];
|
|
47
|
+
// Replace block math ($$...$$) with placeholders
|
|
48
|
+
let processed = markdown.replace(/\$\$([\s\S]*?)\$\$/g, (match) => {
|
|
49
|
+
mathBlocks.push(match);
|
|
50
|
+
return `\n\n%%MATH_BLOCK_${mathBlocks.length - 1}%%\n\n`;
|
|
51
|
+
});
|
|
52
|
+
// Replace inline math ($...$) with placeholders
|
|
53
|
+
// Be careful not to match $$ or currency amounts like $100
|
|
54
|
+
const inlineMathBlocks = [];
|
|
55
|
+
processed = processed.replace(/(?<!\$)\$(?!\$)([^\$\n]+?)\$(?!\$)/g, (match) => {
|
|
56
|
+
inlineMathBlocks.push(match);
|
|
57
|
+
return `%%INLINE_MATH_${inlineMathBlocks.length - 1}%%`;
|
|
58
|
+
});
|
|
59
|
+
// Process with markdown-it
|
|
60
|
+
let html = this.md.render(processed);
|
|
61
|
+
// Restore block math (wrap in div for centering)
|
|
62
|
+
mathBlocks.forEach((block, i) => {
|
|
63
|
+
html = html.replace(`%%MATH_BLOCK_${i}%%`, `<div class="math-block">${block}</div>`);
|
|
64
|
+
});
|
|
65
|
+
// Restore inline math
|
|
66
|
+
inlineMathBlocks.forEach((block, i) => {
|
|
67
|
+
html = html.replace(`%%INLINE_MATH_${i}%%`, block);
|
|
68
|
+
});
|
|
69
|
+
return html;
|
|
44
70
|
}
|
|
45
71
|
/**
|
|
46
72
|
* Check if the parser is available.
|
|
@@ -14,6 +14,19 @@
|
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
16
|
{{#if math_enabled}}
|
|
17
|
+
<style>
|
|
18
|
+
/* Block math centering */
|
|
19
|
+
.math-block {
|
|
20
|
+
display: block;
|
|
21
|
+
text-align: center;
|
|
22
|
+
margin: 1em 0;
|
|
23
|
+
}
|
|
24
|
+
mjx-container[display="true"] {
|
|
25
|
+
display: block !important;
|
|
26
|
+
text-align: center !important;
|
|
27
|
+
margin: 1em 0 !important;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
17
30
|
<script>
|
|
18
31
|
MathJax = {
|
|
19
32
|
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
@@ -14,6 +14,19 @@
|
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
16
|
{{#if math_enabled}}
|
|
17
|
+
<style>
|
|
18
|
+
/* Block math centering */
|
|
19
|
+
.math-block {
|
|
20
|
+
display: block;
|
|
21
|
+
text-align: center;
|
|
22
|
+
margin: 1em 0;
|
|
23
|
+
}
|
|
24
|
+
mjx-container[display="true"] {
|
|
25
|
+
display: block !important;
|
|
26
|
+
text-align: center !important;
|
|
27
|
+
margin: 1em 0 !important;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
17
30
|
<script>
|
|
18
31
|
MathJax = {
|
|
19
32
|
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
@@ -17,7 +17,7 @@ body {
|
|
|
17
17
|
-webkit-text-size-adjust: 100%;
|
|
18
18
|
margin: 0 auto;
|
|
19
19
|
padding: 2rem;
|
|
20
|
-
max-width:
|
|
20
|
+
max-width: 720px;
|
|
21
21
|
color: #f0f6fc;
|
|
22
22
|
background-color: #0d1117;
|
|
23
23
|
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
|
|
@@ -17,7 +17,7 @@ body {
|
|
|
17
17
|
-webkit-text-size-adjust: 100%;
|
|
18
18
|
margin: 0 auto;
|
|
19
19
|
padding: 2rem;
|
|
20
|
-
max-width:
|
|
20
|
+
max-width: 720px;
|
|
21
21
|
color: #1f2328;
|
|
22
22
|
background-color: #ffffff;
|
|
23
23
|
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
|
package/package.json
CHANGED
package/templates/default.html
CHANGED
|
@@ -14,6 +14,19 @@
|
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
16
|
{{#if math_enabled}}
|
|
17
|
+
<style>
|
|
18
|
+
/* Block math centering */
|
|
19
|
+
.math-block {
|
|
20
|
+
display: block;
|
|
21
|
+
text-align: center;
|
|
22
|
+
margin: 1em 0;
|
|
23
|
+
}
|
|
24
|
+
mjx-container[display="true"] {
|
|
25
|
+
display: block !important;
|
|
26
|
+
text-align: center !important;
|
|
27
|
+
margin: 1em 0 !important;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
17
30
|
<script>
|
|
18
31
|
MathJax = {
|
|
19
32
|
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
@@ -14,6 +14,19 @@
|
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
16
|
{{#if math_enabled}}
|
|
17
|
+
<style>
|
|
18
|
+
/* Block math centering */
|
|
19
|
+
.math-block {
|
|
20
|
+
display: block;
|
|
21
|
+
text-align: center;
|
|
22
|
+
margin: 1em 0;
|
|
23
|
+
}
|
|
24
|
+
mjx-container[display="true"] {
|
|
25
|
+
display: block !important;
|
|
26
|
+
text-align: center !important;
|
|
27
|
+
margin: 1em 0 !important;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
17
30
|
<script>
|
|
18
31
|
MathJax = {
|
|
19
32
|
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|