Skip to content

Commit

Permalink
v0.3.0-beta-7: fix options.fracToSlash not working
Browse files Browse the repository at this point in the history
  • Loading branch information
qwinsi committed Jan 28, 2025
1 parent dcdb457 commit 842a561
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tex2typst",
"version": "0.3.0-beta-6",
"version": "0.3.0-beta-7",
"description": "JavaScript library for converting TeX code to Typst",
"type": "module",
"main": "dist/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function tex2typst(tex: string, options?: Tex2TypstOptions): string {
if (options.customTexMacros) {
opt.customTexMacros = options.customTexMacros;
}
if (options.fracToSlash !== undefined) {
opt.fracToSlash = options.fracToSlash;
}
}
const texTree = parseTex(tex, opt.customTexMacros!);
const typstTree = convert_tex_node_to_typst(texTree, opt);
Expand Down
18 changes: 18 additions & 0 deletions test/tex-to-typst.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { describe, it, test, expect } from 'vitest';
import { tex2typst } from '../src/index';

describe('options', () => {
it('fracToSlash = true', function () {
const input = '\\frac{a}{b}';
const expected = 'a/b';
const res = tex2typst(input, { fracToSlash: true });
expect(res).toEqual(expected);
});

it('fracToSlash = false', function () {
const input = '\\frac{a}{b}';
const expected = 'frac(a, b)';
const res = tex2typst(input, { fracToSlash: false });
expect(res).toEqual(expected);
});
});

0 comments on commit 842a561

Please sign in to comment.