tex2typst 0.0.18 → 0.0.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tex2typst",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "JavaScript library for converting TeX code to Typst",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "prebuild": "rimraf dist/",
18
18
  "build:node": "bun build --entrypoints src/index.ts --outdir ./dist --target node --external katex",
19
- "build:browser": "bun build --entrypoints src/index.ts --outdir ./dist --target browser --entry-naming [dir]/tex2typst.min.[ext] --minify",
19
+ "build:browser": "bun build --entrypoints src/tex2typst.ts --outdir ./dist --target browser --entry-naming [dir]/[name].min.[ext] --minify",
20
20
  "build:types": "tsc --project ./tsconfig.json",
21
21
  "build": "npm run build:node && npm run build:browser && npm run build:types",
22
22
  "test": "vitest run"
package/src/index.ts CHANGED
@@ -26,9 +26,4 @@ export function tex2typst(tex: string, options?: Tex2TypstOptions): string {
26
26
  return writer.finalize();
27
27
  }
28
28
 
29
-
30
- if(typeof window !== 'undefined') {
31
- (window as any).tex2typst = tex2typst;
32
- }
33
-
34
29
  export { Tex2TypstOptions };
package/src/map.ts CHANGED
@@ -2,9 +2,6 @@ export const symbolMap = new Map<string, string>([
2
2
  ['gets', 'arrow.l'],
3
3
  ['nonumber', ''],
4
4
  ['vec', 'arrow'],
5
- ['mathbf', 'bold'],
6
- ['boldsymbol', 'bold'],
7
- ['mathfrak', 'frak'],
8
5
  ['neq', 'eq.not'],
9
6
  ['dot', 'dot'],
10
7
  ['ddot', 'dot.double'],
@@ -23,8 +20,13 @@ export const symbolMap = new Map<string, string>([
23
20
  ['underline', 'underline'], // same
24
21
  ['bar', 'macron'],
25
22
 
23
+ ['boldsymbol', 'bold'],
24
+ ['mathbf', 'bold'],
26
25
  ['mathbb', 'bb'],
27
26
  ['mathcal', 'cal'],
27
+ ['mathfrak', 'frak'],
28
+ ['mathsf', 'sans'],
29
+ ['mathtt', 'mono'],
28
30
 
29
31
  ['mathrm', 'upright'],
30
32
  ['rm', 'upright'],
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is the entry point for bundling the .js file for the browser.
3
+ */
4
+
5
+ import { tex2typst } from './index';
6
+
7
+ if(typeof window !== 'undefined') {
8
+ (window as any).tex2typst = tex2typst;
9
+ }
package/src/writer.ts CHANGED
@@ -172,6 +172,19 @@ export class TypstWriter {
172
172
  this.queue.push({ type: 'atom', content: ')'});
173
173
  this.insideFunctionDepth --;
174
174
  return;
175
+ } else if (node.content === '\\mathbf') {
176
+ this.append({ type: 'symbol', content: 'upright' });
177
+ this.insideFunctionDepth ++;
178
+ this.queue.push({ type: 'atom', content: '('});
179
+ this.queue.push(func_symbol);
180
+ this.insideFunctionDepth ++;
181
+ this.queue.push({ type: 'atom', content: '('});
182
+ this.append(arg0);
183
+ this.queue.push({ type: 'atom', content: ')'});
184
+ this.insideFunctionDepth --;
185
+ this.queue.push({ type: 'atom', content: ')'});
186
+ this.insideFunctionDepth --;
187
+ return;
175
188
  } else if (node.content === '\\mathbb') {
176
189
  const body = node.args![0];
177
190
  if (body.type === 'symbol' && /^[A-Z]$/.test(body.content)) {