vimd 0.3.11 → 0.3.13
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 +62 -23
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +2 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +2 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +4 -0
- package/dist/config/types.d.ts +6 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/validator.d.ts +1 -0
- package/dist/config/validator.d.ts.map +1 -1
- package/dist/config/validator.js +8 -0
- package/dist/core/converter.d.ts.map +1 -1
- package/dist/core/converter.js +10 -0
- package/dist/core/parser/markdown-it-parser.d.ts +2 -1
- package/dist/core/parser/markdown-it-parser.d.ts.map +1 -1
- package/dist/core/parser/markdown-it-parser.js +9 -1
- package/dist/core/parser/pandoc-parser.d.ts +3 -2
- package/dist/core/parser/pandoc-parser.d.ts.map +1 -1
- package/dist/core/parser/pandoc-parser.js +11 -1
- package/dist/core/parser/parser-factory.d.ts +5 -3
- package/dist/core/parser/parser-factory.d.ts.map +1 -1
- package/dist/core/parser/parser-factory.js +7 -5
- package/dist/templates/default.html +13 -0
- package/dist/templates/standalone.html +13 -0
- package/package.json +2 -1
- package/templates/default.html +13 -0
- package/templates/standalone.html +13 -0
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
### インストール
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
npm install -g vimd@0.
|
|
68
|
+
npm install -g vimd@0.3.11
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
**現在の安定版: v0.2.4**
|
|
@@ -109,11 +109,13 @@ v0.3.x は内部アーキテクチャを刷新した実験的バージョンで
|
|
|
109
109
|
安定した動作を求める場合は v0.2.4 をご利用ください。
|
|
110
110
|
|
|
111
111
|
安定版のインストール:
|
|
112
|
+
|
|
112
113
|
```bash
|
|
113
114
|
npm install -g vimd@0.2.4
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
最新版(実験的)のインストール:
|
|
118
|
+
|
|
117
119
|
```bash
|
|
118
120
|
npm install -g vimd@latest
|
|
119
121
|
```
|
|
@@ -122,14 +124,14 @@ npm install -g vimd@latest
|
|
|
122
124
|
|
|
123
125
|
## コマンド
|
|
124
126
|
|
|
125
|
-
| コマンド
|
|
126
|
-
|
|
127
|
-
| `vimd dev <file>`
|
|
128
|
-
| `vimd build <file>` | 静的HTMLを生成
|
|
129
|
-
| `vimd theme`
|
|
130
|
-
| `vimd config`
|
|
131
|
-
| `vimd kill`
|
|
132
|
-
| `vimd reset`
|
|
127
|
+
| コマンド | 説明 |
|
|
128
|
+
| ------------------- | ------------------------------ |
|
|
129
|
+
| `vimd dev <file>` | ライブプレビューサーバーを起動 |
|
|
130
|
+
| `vimd build <file>` | 静的HTMLを生成 |
|
|
131
|
+
| `vimd theme` | テーマを対話的に変更 |
|
|
132
|
+
| `vimd config` | 設定を対話的に編集 |
|
|
133
|
+
| `vimd kill` | 実行中のセッションを終了 |
|
|
134
|
+
| `vimd reset` | 設定をデフォルトにリセット |
|
|
133
135
|
|
|
134
136
|
### オプション
|
|
135
137
|
|
|
@@ -163,34 +165,71 @@ vimd reset --yes # 確認なしでリセット
|
|
|
163
165
|
```javascript
|
|
164
166
|
export default {
|
|
165
167
|
theme: 'github',
|
|
166
|
-
port: 38080,
|
|
168
|
+
port: 38080, // デフォルト: 38080(v0.2.1で変更)
|
|
167
169
|
open: true,
|
|
168
|
-
devParser: 'markdown-it',
|
|
169
|
-
buildParser: 'pandoc',
|
|
170
|
+
devParser: 'markdown-it', // dev用パーサー(デフォルト: markdown-it)
|
|
171
|
+
buildParser: 'pandoc', // build用パーサー(デフォルト: pandoc)
|
|
170
172
|
};
|
|
171
173
|
```
|
|
172
174
|
|
|
173
175
|
### パーサー設定
|
|
174
176
|
|
|
175
|
-
| パーサー
|
|
176
|
-
|
|
177
|
+
| パーサー | 特徴 | 用途 |
|
|
178
|
+
| ------------- | ---------------- | ------------------ |
|
|
177
179
|
| `markdown-it` | 高速、pandoc不要 | 開発時のプレビュー |
|
|
178
|
-
| `pandoc`
|
|
180
|
+
| `pandoc` | 高品質、多機能 | 最終出力の生成 |
|
|
179
181
|
|
|
180
182
|
詳細な設定オプションは [docs/ja/api.md](docs/ja/api.md) を参照してください。
|
|
181
183
|
|
|
184
|
+
### 数式サポート
|
|
185
|
+
|
|
186
|
+
vimd は MathJax を使用した TeX 数式表示に対応しています(v0.3.12以降)。
|
|
187
|
+
|
|
188
|
+
```markdown
|
|
189
|
+
インライン数式: $E = mc^2$
|
|
190
|
+
|
|
191
|
+
ブロック数式:
|
|
192
|
+
$$
|
|
193
|
+
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
|
|
194
|
+
$$
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
bussproofs(証明図)にも対応しています:
|
|
198
|
+
|
|
199
|
+
```markdown
|
|
200
|
+
$$
|
|
201
|
+
\begin{prooftree}
|
|
202
|
+
\AxiomC{$A$}
|
|
203
|
+
\AxiomC{$B$}
|
|
204
|
+
\BinaryInfC{$A \land B$}
|
|
205
|
+
\end{prooftree}
|
|
206
|
+
$$
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
数式サポートの設定:
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
// ~/.vimd/config.js
|
|
213
|
+
export default {
|
|
214
|
+
math: {
|
|
215
|
+
enabled: true, // デフォルト: true
|
|
216
|
+
engine: 'mathjax', // 'mathjax' または 'katex'
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
182
221
|
---
|
|
183
222
|
|
|
184
223
|
## Why vimd?
|
|
185
224
|
|
|
186
|
-
| 特徴
|
|
187
|
-
|
|
188
|
-
| セットアップ
|
|
189
|
-
| 外部依存
|
|
190
|
-
| 変換品質
|
|
191
|
-
| テーマ
|
|
192
|
-
| 設定ファイル
|
|
193
|
-
| ライブリロード | 自動
|
|
225
|
+
| 特徴 | vimd | 他のツール |
|
|
226
|
+
| -------------- | --------------------------- | -------------------------- |
|
|
227
|
+
| セットアップ | `npm i -g vimd` | 複雑な設定が必要な場合も |
|
|
228
|
+
| 外部依存 | なし(pandocはオプション) | pandoc必須が多い |
|
|
229
|
+
| 変換品質 | markdown-it / pandoc 選択可 | 固定 |
|
|
230
|
+
| テーマ | 5種類組み込み | 別途設定が必要 |
|
|
231
|
+
| 設定ファイル | プロジェクト外 (`~/.vimd/`) | プロジェクト内が多い |
|
|
232
|
+
| ライブリロード | 自動 | 手動リロードが必要な場合も |
|
|
194
233
|
|
|
195
234
|
---
|
|
196
235
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AASA,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AASA,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAoEf"}
|
|
@@ -39,12 +39,13 @@ export async function buildCommand(filePath, options) {
|
|
|
39
39
|
...config.pandoc,
|
|
40
40
|
standalone: true, // build always uses standalone
|
|
41
41
|
};
|
|
42
|
-
const parser = ParserFactory.create(parserType, pandocOptions);
|
|
42
|
+
const parser = ParserFactory.create(parserType, pandocOptions, config.math);
|
|
43
43
|
const converter = new MarkdownConverter({
|
|
44
44
|
theme: config.theme,
|
|
45
45
|
pandocOptions: pandocOptions,
|
|
46
46
|
customCSS: config.css,
|
|
47
47
|
template: config.template || undefined,
|
|
48
|
+
mathEnabled: config.math?.enabled ?? true,
|
|
48
49
|
});
|
|
49
50
|
converter.setParser(parser);
|
|
50
51
|
// 7. Execute conversion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/dev.ts"],"names":[],"mappings":"AAcA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/dev.ts"],"names":[],"mappings":"AAcA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAyKf"}
|
package/dist/cli/commands/dev.js
CHANGED
|
@@ -68,12 +68,13 @@ export async function devCommand(filePath, options) {
|
|
|
68
68
|
const htmlFileName = `vimd-preview-${basename}.html`;
|
|
69
69
|
const htmlPath = path.join(sourceDir, htmlFileName);
|
|
70
70
|
// 9. Prepare converter with selected parser
|
|
71
|
-
const parser = ParserFactory.create(parserType, config.pandoc);
|
|
71
|
+
const parser = ParserFactory.create(parserType, config.pandoc, config.math);
|
|
72
72
|
const converter = new MarkdownConverter({
|
|
73
73
|
theme: config.theme,
|
|
74
74
|
pandocOptions: config.pandoc,
|
|
75
75
|
customCSS: config.css,
|
|
76
76
|
template: config.template,
|
|
77
|
+
mathEnabled: config.math?.enabled ?? true,
|
|
77
78
|
});
|
|
78
79
|
converter.setParser(parser);
|
|
79
80
|
// 10. Initial conversion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,cAAc,EAAE,UAwB5B,CAAC"}
|
package/dist/config/defaults.js
CHANGED
package/dist/config/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface VimdConfig {
|
|
|
13
13
|
pandoc: PandocConfig;
|
|
14
14
|
watch: WatchConfig;
|
|
15
15
|
build?: BuildConfig;
|
|
16
|
+
math: MathConfig;
|
|
16
17
|
devParser: ConfigParserType;
|
|
17
18
|
buildParser: ConfigParserType;
|
|
18
19
|
}
|
|
@@ -32,6 +33,10 @@ export interface BuildConfig {
|
|
|
32
33
|
inlineCSS: boolean;
|
|
33
34
|
standalone: boolean;
|
|
34
35
|
}
|
|
36
|
+
export interface MathConfig {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
engine: 'mathjax' | 'katex';
|
|
39
|
+
}
|
|
35
40
|
export interface ThemeInfo {
|
|
36
41
|
name: string;
|
|
37
42
|
displayName: string;
|
|
@@ -49,6 +54,7 @@ export interface ConverterConfig {
|
|
|
49
54
|
pandocOptions: PandocConfig;
|
|
50
55
|
customCSS?: string;
|
|
51
56
|
template?: string;
|
|
57
|
+
mathEnabled?: boolean;
|
|
52
58
|
}
|
|
53
59
|
export declare function defineConfig(config: Partial<VimdConfig>): VimdConfig;
|
|
54
60
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,QAAQ,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,QAAQ,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAEpE"}
|
|
@@ -6,6 +6,7 @@ export interface ValidationResult {
|
|
|
6
6
|
export declare class ConfigValidator {
|
|
7
7
|
static validatePort(port: number): boolean;
|
|
8
8
|
static validateTheme(theme: string): boolean;
|
|
9
|
+
static validateMathEngine(engine: string): boolean;
|
|
9
10
|
static validate(config: VimdConfig): ValidationResult;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAKD,qBAAa,eAAe;IAC1B,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1C,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI5C,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIlD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB;CA8CtD"}
|
package/dist/config/validator.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const VALID_THEMES = ['github', 'minimal', 'dark', 'academic', 'technical'];
|
|
2
|
+
const VALID_MATH_ENGINES = ['mathjax', 'katex'];
|
|
2
3
|
export class ConfigValidator {
|
|
3
4
|
static validatePort(port) {
|
|
4
5
|
return Number.isInteger(port) && port > 0 && port <= 65535;
|
|
@@ -6,6 +7,9 @@ export class ConfigValidator {
|
|
|
6
7
|
static validateTheme(theme) {
|
|
7
8
|
return VALID_THEMES.includes(theme);
|
|
8
9
|
}
|
|
10
|
+
static validateMathEngine(engine) {
|
|
11
|
+
return VALID_MATH_ENGINES.includes(engine);
|
|
12
|
+
}
|
|
9
13
|
static validate(config) {
|
|
10
14
|
const errors = [];
|
|
11
15
|
// Port validation
|
|
@@ -30,6 +34,10 @@ export class ConfigValidator {
|
|
|
30
34
|
if (config.watch.debounce < 0) {
|
|
31
35
|
errors.push(`Invalid debounce: ${config.watch.debounce} (must be >= 0)`);
|
|
32
36
|
}
|
|
37
|
+
// Math engine validation
|
|
38
|
+
if (config.math && !this.validateMathEngine(config.math.engine)) {
|
|
39
|
+
errors.push(`Invalid math engine: ${config.math.engine} (must be 'mathjax' or 'katex')`);
|
|
40
|
+
}
|
|
33
41
|
return {
|
|
34
42
|
valid: errors.length === 0,
|
|
35
43
|
errors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../src/core/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQ3C,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,MAAM,CAAuB;gBAEjB,MAAM,EAAE,eAAe;IAE3C;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAIpB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWpD;;;OAGG;YACW,uBAAuB;IAiB/B,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../src/core/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQ3C,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,MAAM,CAAuB;gBAEjB,MAAM,EAAE,eAAe;IAE3C;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAIpB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWpD;;;OAGG;YACW,uBAAuB;IAiB/B,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwC1D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhE,OAAO,CAAC,eAAe;CA+BxB"}
|
package/dist/core/converter.js
CHANGED
|
@@ -76,6 +76,16 @@ export class MarkdownConverter {
|
|
|
76
76
|
else {
|
|
77
77
|
html = html.replace(/\{\{#if custom_css\}\}[\s\S]*?\{\{\/if\}\}/g, '');
|
|
78
78
|
}
|
|
79
|
+
// Math support
|
|
80
|
+
if (this.config.mathEnabled) {
|
|
81
|
+
// Keep the math_enabled block as-is (MathJax will be loaded)
|
|
82
|
+
html = html.replace(/\{\{#if math_enabled\}\}/g, '');
|
|
83
|
+
html = html.replace(/\{\{\/if\}\}/g, '');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Remove the math_enabled block entirely
|
|
87
|
+
html = html.replace(/\{\{#if math_enabled\}\}[\s\S]*?\{\{\/if\}\}/g, '');
|
|
88
|
+
}
|
|
79
89
|
return html;
|
|
80
90
|
}
|
|
81
91
|
async writeHTML(html, outputPath) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Parser } from './types.js';
|
|
2
|
+
import { MathConfig } from '../../config/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Markdown parser using markdown-it library.
|
|
4
5
|
* Provides fast markdown to HTML conversion with GFM support.
|
|
@@ -6,7 +7,7 @@ import { Parser } from './types.js';
|
|
|
6
7
|
export declare class MarkdownItParser implements Parser {
|
|
7
8
|
readonly name = "markdown-it";
|
|
8
9
|
private md;
|
|
9
|
-
constructor();
|
|
10
|
+
constructor(mathConfig?: MathConfig);
|
|
10
11
|
/**
|
|
11
12
|
* Convert markdown to HTML.
|
|
12
13
|
* @param markdown - The markdown content to convert
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-it-parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser/markdown-it-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-it-parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser/markdown-it-parser.ts"],"names":[],"mappings":"AAOA,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,UAAU,CAAC,EAAE,UAAU;IA8BnC;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
|
@@ -3,12 +3,13 @@ import MarkdownIt from 'markdown-it';
|
|
|
3
3
|
import hljs from 'highlight.js';
|
|
4
4
|
import strikethrough from 'markdown-it-strikethrough-alt';
|
|
5
5
|
import taskLists from 'markdown-it-task-lists';
|
|
6
|
+
import texmath from 'markdown-it-texmath';
|
|
6
7
|
/**
|
|
7
8
|
* Markdown parser using markdown-it library.
|
|
8
9
|
* Provides fast markdown to HTML conversion with GFM support.
|
|
9
10
|
*/
|
|
10
11
|
export class MarkdownItParser {
|
|
11
|
-
constructor() {
|
|
12
|
+
constructor(mathConfig) {
|
|
12
13
|
this.name = 'markdown-it';
|
|
13
14
|
this.md = new MarkdownIt({
|
|
14
15
|
html: true,
|
|
@@ -29,6 +30,13 @@ export class MarkdownItParser {
|
|
|
29
30
|
// Enable GFM plugins
|
|
30
31
|
this.md.use(strikethrough); // ~~strikethrough~~
|
|
31
32
|
this.md.use(taskLists); // - [ ] task list
|
|
33
|
+
// Enable math support
|
|
34
|
+
if (mathConfig?.enabled) {
|
|
35
|
+
this.md.use(texmath, {
|
|
36
|
+
engine: { name: mathConfig.engine },
|
|
37
|
+
delimiters: 'dollars',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* Convert markdown to HTML.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Parser } from './types.js';
|
|
2
|
-
import { PandocConfig } from '../../config/types.js';
|
|
2
|
+
import { MathConfig, PandocConfig } from '../../config/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Markdown parser using pandoc.
|
|
5
5
|
* Provides high-quality markdown to HTML conversion with extensive features.
|
|
@@ -7,7 +7,8 @@ import { PandocConfig } from '../../config/types.js';
|
|
|
7
7
|
export declare class PandocParser implements Parser {
|
|
8
8
|
readonly name = "pandoc";
|
|
9
9
|
private config;
|
|
10
|
-
|
|
10
|
+
private mathConfig?;
|
|
11
|
+
constructor(config?: Partial<PandocConfig>, mathConfig?: MathConfig);
|
|
11
12
|
/**
|
|
12
13
|
* Convert markdown to HTML using pandoc.
|
|
13
14
|
* @param markdown - The markdown content to convert
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pandoc-parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser/pandoc-parser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"pandoc-parser.d.ts","sourceRoot":"","sources":["../../../src/core/parser/pandoc-parser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAYjE;;;GAGG;AACH,qBAAa,YAAa,YAAW,MAAM;IACzC,QAAQ,CAAC,IAAI,YAAY;IACzB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAa;gBAEpB,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,EAAE,UAAU,CAAC,EAAE,UAAU;IAKvE;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB9C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;OAEG;IACH,OAAO,CAAC,eAAe;CAwCxB"}
|
|
@@ -14,9 +14,10 @@ const DEFAULT_PANDOC_CONFIG = {
|
|
|
14
14
|
* Provides high-quality markdown to HTML conversion with extensive features.
|
|
15
15
|
*/
|
|
16
16
|
export class PandocParser {
|
|
17
|
-
constructor(config = {}) {
|
|
17
|
+
constructor(config = {}, mathConfig) {
|
|
18
18
|
this.name = 'pandoc';
|
|
19
19
|
this.config = { ...DEFAULT_PANDOC_CONFIG, ...config };
|
|
20
|
+
this.mathConfig = mathConfig;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* Convert markdown to HTML using pandoc.
|
|
@@ -78,6 +79,15 @@ export class PandocParser {
|
|
|
78
79
|
args.push(`--metadata=${key}:"${value}"`);
|
|
79
80
|
});
|
|
80
81
|
}
|
|
82
|
+
// Math support
|
|
83
|
+
if (this.mathConfig?.enabled) {
|
|
84
|
+
if (this.mathConfig.engine === 'mathjax') {
|
|
85
|
+
args.push('--mathjax');
|
|
86
|
+
}
|
|
87
|
+
else if (this.mathConfig.engine === 'katex') {
|
|
88
|
+
args.push('--katex');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
81
91
|
return args;
|
|
82
92
|
}
|
|
83
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Parser, ParserType } from './types.js';
|
|
2
|
-
import { PandocConfig } from '../../config/types.js';
|
|
2
|
+
import { PandocConfig, MathConfig } from '../../config/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Factory for creating parser instances.
|
|
5
5
|
* Provides methods to create parsers by type and with fallback support.
|
|
@@ -9,19 +9,21 @@ export declare class ParserFactory {
|
|
|
9
9
|
* Create a parser instance by type.
|
|
10
10
|
* @param type - The type of parser to create
|
|
11
11
|
* @param pandocConfig - Optional configuration for pandoc parser
|
|
12
|
+
* @param mathConfig - Optional configuration for math support
|
|
12
13
|
* @returns A parser instance
|
|
13
14
|
* @throws Error if the parser type is unknown
|
|
14
15
|
*/
|
|
15
|
-
static create(type: ParserType, pandocConfig?: Partial<PandocConfig
|
|
16
|
+
static create(type: ParserType, pandocConfig?: Partial<PandocConfig>, mathConfig?: MathConfig): Parser;
|
|
16
17
|
/**
|
|
17
18
|
* Create a parser with fallback support.
|
|
18
19
|
* If the preferred parser is not available, falls back to markdown-it.
|
|
19
20
|
* @param preferred - The preferred parser type
|
|
20
21
|
* @param pandocConfig - Optional configuration for pandoc parser
|
|
22
|
+
* @param mathConfig - Optional configuration for math support
|
|
21
23
|
* @returns A parser instance that is guaranteed to be available
|
|
22
24
|
* @throws Error if pandoc is preferred but not installed (no silent fallback)
|
|
23
25
|
*/
|
|
24
|
-
static createWithFallback(preferred: ParserType, pandocConfig?: Partial<PandocConfig
|
|
26
|
+
static createWithFallback(preferred: ParserType, pandocConfig?: Partial<PandocConfig>, mathConfig?: MathConfig): Promise<Parser>;
|
|
25
27
|
/**
|
|
26
28
|
* Get the default parser type for dev mode.
|
|
27
29
|
* @returns 'markdown-it' as the default for fast preview
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-factory.d.ts","sourceRoot":"","sources":["../../../src/core/parser/parser-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"parser-factory.d.ts","sourceRoot":"","sources":["../../../src/core/parser/parser-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;GAGG;AACH,qBAAa,aAAa;IACxB;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,UAAU,EAChB,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EACpC,UAAU,CAAC,EAAE,UAAU,GACtB,MAAM;IAaT;;;;;;;;OAQG;WACU,kBAAkB,CAC7B,SAAS,EAAE,UAAU,EACrB,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EACpC,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,MAAM,CAAC;IAmBlB;;;OAGG;IACH,MAAM,CAAC,mBAAmB,IAAI,UAAU;IAIxC;;;OAGG;IACH,MAAM,CAAC,qBAAqB,IAAI,UAAU;CAG3C"}
|
|
@@ -10,15 +10,16 @@ export class ParserFactory {
|
|
|
10
10
|
* Create a parser instance by type.
|
|
11
11
|
* @param type - The type of parser to create
|
|
12
12
|
* @param pandocConfig - Optional configuration for pandoc parser
|
|
13
|
+
* @param mathConfig - Optional configuration for math support
|
|
13
14
|
* @returns A parser instance
|
|
14
15
|
* @throws Error if the parser type is unknown
|
|
15
16
|
*/
|
|
16
|
-
static create(type, pandocConfig) {
|
|
17
|
+
static create(type, pandocConfig, mathConfig) {
|
|
17
18
|
switch (type) {
|
|
18
19
|
case 'markdown-it':
|
|
19
|
-
return new MarkdownItParser();
|
|
20
|
+
return new MarkdownItParser(mathConfig);
|
|
20
21
|
case 'pandoc':
|
|
21
|
-
return new PandocParser(pandocConfig);
|
|
22
|
+
return new PandocParser(pandocConfig, mathConfig);
|
|
22
23
|
default:
|
|
23
24
|
// TypeScript exhaustive check
|
|
24
25
|
const _exhaustive = type;
|
|
@@ -30,11 +31,12 @@ export class ParserFactory {
|
|
|
30
31
|
* If the preferred parser is not available, falls back to markdown-it.
|
|
31
32
|
* @param preferred - The preferred parser type
|
|
32
33
|
* @param pandocConfig - Optional configuration for pandoc parser
|
|
34
|
+
* @param mathConfig - Optional configuration for math support
|
|
33
35
|
* @returns A parser instance that is guaranteed to be available
|
|
34
36
|
* @throws Error if pandoc is preferred but not installed (no silent fallback)
|
|
35
37
|
*/
|
|
36
|
-
static async createWithFallback(preferred, pandocConfig) {
|
|
37
|
-
const parser = this.create(preferred, pandocConfig);
|
|
38
|
+
static async createWithFallback(preferred, pandocConfig, mathConfig) {
|
|
39
|
+
const parser = this.create(preferred, pandocConfig, mathConfig);
|
|
38
40
|
if (await parser.isAvailable()) {
|
|
39
41
|
return parser;
|
|
40
42
|
}
|
|
@@ -13,6 +13,19 @@
|
|
|
13
13
|
{{custom_css}}
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
|
+
{{#if math_enabled}}
|
|
17
|
+
<script>
|
|
18
|
+
MathJax = {
|
|
19
|
+
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
20
|
+
tex: {
|
|
21
|
+
packages: {'[+]': ['bussproofs', 'ams', 'physics']},
|
|
22
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
23
|
+
displayMath: [['$$', '$$'], ['\\[', '\\]']]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
28
|
+
{{/if}}
|
|
16
29
|
</head>
|
|
17
30
|
<body>
|
|
18
31
|
<div class="markdown-body">
|
|
@@ -13,6 +13,19 @@
|
|
|
13
13
|
{{custom_css}}
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
|
+
{{#if math_enabled}}
|
|
17
|
+
<script>
|
|
18
|
+
MathJax = {
|
|
19
|
+
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
20
|
+
tex: {
|
|
21
|
+
packages: {'[+]': ['bussproofs', 'ams', 'physics']},
|
|
22
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
23
|
+
displayMath: [['$$', '$$'], ['\\[', '\\]']]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
28
|
+
{{/if}}
|
|
16
29
|
</head>
|
|
17
30
|
<body>
|
|
18
31
|
<div class="markdown-body">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vimd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Real-time Markdown preview tool with pandoc (view markdown)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"markdown-it": "^14.1.0",
|
|
77
77
|
"markdown-it-strikethrough-alt": "^1.0.0",
|
|
78
78
|
"markdown-it-task-lists": "^2.1.1",
|
|
79
|
+
"markdown-it-texmath": "^1.0.0",
|
|
79
80
|
"open": "^9.1.0",
|
|
80
81
|
"polka": "^0.5.2",
|
|
81
82
|
"sirv": "^3.0.2",
|
package/templates/default.html
CHANGED
|
@@ -13,6 +13,19 @@
|
|
|
13
13
|
{{custom_css}}
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
|
+
{{#if math_enabled}}
|
|
17
|
+
<script>
|
|
18
|
+
MathJax = {
|
|
19
|
+
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
20
|
+
tex: {
|
|
21
|
+
packages: {'[+]': ['bussproofs', 'ams', 'physics']},
|
|
22
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
23
|
+
displayMath: [['$$', '$$'], ['\\[', '\\]']]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
28
|
+
{{/if}}
|
|
16
29
|
</head>
|
|
17
30
|
<body>
|
|
18
31
|
<div class="markdown-body">
|
|
@@ -13,6 +13,19 @@
|
|
|
13
13
|
{{custom_css}}
|
|
14
14
|
</style>
|
|
15
15
|
{{/if}}
|
|
16
|
+
{{#if math_enabled}}
|
|
17
|
+
<script>
|
|
18
|
+
MathJax = {
|
|
19
|
+
loader: {load: ['[tex]/bussproofs', '[tex]/ams', '[tex]/physics']},
|
|
20
|
+
tex: {
|
|
21
|
+
packages: {'[+]': ['bussproofs', 'ams', 'physics']},
|
|
22
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
23
|
+
displayMath: [['$$', '$$'], ['\\[', '\\]']]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
28
|
+
{{/if}}
|
|
16
29
|
</head>
|
|
17
30
|
<body>
|
|
18
31
|
<div class="markdown-body">
|