Comparing version 0.0.18 to 0.0.19
@@ -249,5 +249,2 @@ // src/parser.ts | ||
["vec", "arrow"], | ||
["mathbf", "bold"], | ||
["boldsymbol", "bold"], | ||
["mathfrak", "frak"], | ||
["neq", "eq.not"], | ||
@@ -270,4 +267,9 @@ ["dot", "dot"], | ||
["bar", "macron"], | ||
["boldsymbol", "bold"], | ||
["mathbf", "bold"], | ||
["mathbb", "bb"], | ||
["mathcal", "cal"], | ||
["mathfrak", "frak"], | ||
["mathsf", "sans"], | ||
["mathtt", "mono"], | ||
["mathrm", "upright"], | ||
@@ -669,2 +671,15 @@ ["rm", "upright"], | ||
return; | ||
} else if (node.content === "\\mathbf") { | ||
this.append({ type: "symbol", content: "upright" }); | ||
this.insideFunctionDepth++; | ||
this.queue.push({ type: "atom", content: "(" }); | ||
this.queue.push(func_symbol); | ||
this.insideFunctionDepth++; | ||
this.queue.push({ type: "atom", content: "(" }); | ||
this.append(arg0); | ||
this.queue.push({ type: "atom", content: ")" }); | ||
this.insideFunctionDepth--; | ||
this.queue.push({ type: "atom", content: ")" }); | ||
this.insideFunctionDepth--; | ||
return; | ||
} else if (node.content === "\\mathbb") { | ||
@@ -835,7 +850,4 @@ const body = node.args[0]; | ||
} | ||
if (typeof window !== "undefined") { | ||
window.tex2typst = tex2typst; | ||
} | ||
export { | ||
tex2typst | ||
}; |
{ | ||
"name": "tex2typst", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "JavaScript library for converting TeX code to Typst", | ||
@@ -19,3 +19,3 @@ "type": "module", | ||
"build:node": "bun build --entrypoints src/index.ts --outdir ./dist --target node --external katex", | ||
"build:browser": "bun build --entrypoints src/index.ts --outdir ./dist --target browser --entry-naming [dir]/tex2typst.min.[ext] --minify", | ||
"build:browser": "bun build --entrypoints src/tex2typst.ts --outdir ./dist --target browser --entry-naming [dir]/[name].min.[ext] --minify", | ||
"build:types": "tsc --project ./tsconfig.json", | ||
@@ -22,0 +22,0 @@ "build": "npm run build:node && npm run build:browser && npm run build:types", |
@@ -10,2 +10,4 @@ # tex2typst | ||
## Installing it in a Node.js project | ||
```bash | ||
@@ -15,2 +17,12 @@ npm install tex2typst | ||
## Or just loading it in a web page | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/tex2typst@0.0.19/dist/tex2typst.min.js"></script> | ||
<!-- or --> | ||
<script src="https://unpkg.com/tex2typst@0.0.19/dist/tex2typst.min.js"></script> | ||
``` | ||
Replace `0.0.19` with the latest version number in case this README is outdated. | ||
## Usage | ||
@@ -21,3 +33,3 @@ | ||
```javascript | ||
import { parseTex, tex2typst } from 'tex2typst'; | ||
import { tex2typst } from 'tex2typst'; | ||
@@ -29,4 +41,7 @@ let output = tex2typst("\\zeta(s) = \\sum_{n=1}^{\\infty}\\frac{1}{n^s}"); | ||
### Advanced settings | ||
If you are using the library in a web page via a `<script>` tag, you don't need the line of `import`, function `tex2typst` should be available in the global scope. | ||
### Advanced options | ||
- custom TeX macros/commands | ||
@@ -40,3 +55,3 @@ | ||
let input = "y = \\sgn(x)"; | ||
const output = tex2typst(input, {customTexMacros: macros}); | ||
let output = tex2typst(input, {customTexMacros: macros}); | ||
console.log(output); | ||
@@ -43,0 +58,0 @@ // y = op("sgn")(x) |
@@ -29,7 +29,2 @@ import { parseTex } from "./parser"; | ||
if(typeof window !== 'undefined') { | ||
(window as any).tex2typst = tex2typst; | ||
} | ||
export { Tex2TypstOptions }; |
@@ -5,5 +5,2 @@ export const symbolMap = new Map<string, string>([ | ||
['vec', 'arrow'], | ||
['mathbf', 'bold'], | ||
['boldsymbol', 'bold'], | ||
['mathfrak', 'frak'], | ||
['neq', 'eq.not'], | ||
@@ -27,4 +24,9 @@ ['dot', 'dot'], | ||
['boldsymbol', 'bold'], | ||
['mathbf', 'bold'], | ||
['mathbb', 'bb'], | ||
['mathcal', 'cal'], | ||
['mathfrak', 'frak'], | ||
['mathsf', 'sans'], | ||
['mathtt', 'mono'], | ||
@@ -31,0 +33,0 @@ ['mathrm', 'upright'], |
@@ -175,2 +175,15 @@ import { symbolMap } from "./map"; | ||
return; | ||
} else if (node.content === '\\mathbf') { | ||
this.append({ type: 'symbol', content: 'upright' }); | ||
this.insideFunctionDepth ++; | ||
this.queue.push({ type: 'atom', content: '('}); | ||
this.queue.push(func_symbol); | ||
this.insideFunctionDepth ++; | ||
this.queue.push({ type: 'atom', content: '('}); | ||
this.append(arg0); | ||
this.queue.push({ type: 'atom', content: ')'}); | ||
this.insideFunctionDepth --; | ||
this.queue.push({ type: 'atom', content: ')'}); | ||
this.insideFunctionDepth --; | ||
return; | ||
} else if (node.content === '\\mathbb') { | ||
@@ -177,0 +190,0 @@ const body = node.args![0]; |
@@ -112,4 +112,5 @@ { | ||
"exclude": [ | ||
"src/tex2typst.ts", | ||
"tests/**/*" | ||
] | ||
} |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1308070
19
30468
69