vimd 0.3.10 → 0.3.12

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 CHANGED
@@ -65,7 +65,7 @@
65
65
  ### インストール
66
66
 
67
67
  ```bash
68
- npm install -g vimd@0.2.4
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, // デフォルト: 38080(v0.2.1で変更)
168
+ port: 38080, // デフォルト: 38080(v0.2.1で変更)
167
169
  open: true,
168
- devParser: 'markdown-it', // dev用パーサー(デフォルト: markdown-it)
169
- buildParser: 'pandoc', // build用パーサー(デフォルト: 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
- | 特徴 | vimd | 他のツール |
187
- |------|------|-----------|
188
- | セットアップ | `npm i -g vimd` | 複雑な設定が必要な場合も |
189
- | 外部依存 | なし(pandocはオプション) | pandoc必須が多い |
190
- | 変換品質 | markdown-it / pandoc 選択可 | 固定 |
191
- | テーマ | 5種類組み込み | 別途設定が必要 |
192
- | 設定ファイル | プロジェクト外 (`~/.vimd/`) | プロジェクト内が多い |
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":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,cAAc,EAAE,UAoB5B,CAAC"}
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"}
@@ -16,6 +16,10 @@ export const DEFAULT_CONFIG = {
16
16
  inlineCSS: false,
17
17
  standalone: true,
18
18
  },
19
+ math: {
20
+ enabled: true,
21
+ engine: 'mathjax',
22
+ },
19
23
  devParser: 'markdown-it',
20
24
  buildParser: 'pandoc',
21
25
  };
@@ -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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atePort(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;AAID,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,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB;CAuCtD"}
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"}
@@ -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;IA8B1D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhE,OAAO,CAAC,eAAe;CA+BxB"}
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"}
@@ -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":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,MAAM;IAC7C,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,OAAO,CAAC,EAAE,CAAa;;IAwBvB;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
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
- constructor(config?: Partial<PandocConfig>);
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;AAYrD;;;GAGG;AACH,qBAAa,YAAa,YAAW,MAAM;IACzC,QAAQ,CAAC,IAAI,YAAY;IACzB,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM;IAI9C;;;;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;CA+BxB"}
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
  }
@@ -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.10",
3
+ "version": "0.3.12",
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",
@@ -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">