tex2typst 0.0.16 → 0.0.17

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/dist/parser.js CHANGED
@@ -105,10 +105,11 @@ function katexNodeToTexNode(node) {
105
105
  if (right === "\\}") {
106
106
  right = "}";
107
107
  }
108
+ const is_atom = (str) => (['(', ')', '[', ']', '{', '}'].includes(str));
108
109
  res.args = [
109
- { type: 'atom', content: left },
110
+ { type: is_atom(left) ? 'atom' : 'symbol', content: left },
110
111
  body,
111
- { type: 'atom', content: right }
112
+ { type: is_atom(right) ? 'atom' : 'symbol', content: right }
112
113
  ];
113
114
  break;
114
115
  }
package/dist/writer.js CHANGED
@@ -123,7 +123,7 @@ class TypstWriter {
123
123
  else if (node.type === 'leftright') {
124
124
  const [left, body, right] = node.args;
125
125
  // These pairs will be handled by Typst compiler by default. No need to add lr()
126
- if (["[]", "()", "{}"].includes(left.content + right.content)) {
126
+ if (["[]", "()", "{}", "\\lfloor\\rfloor", "\\lceil\\rceil"].includes(left.content + right.content)) {
127
127
  this.append(left);
128
128
  this.append(body);
129
129
  this.append(right);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tex2typst",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "JavaScript library for converting TeX code to Typst",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/parser.ts CHANGED
@@ -101,10 +101,11 @@ export function katexNodeToTexNode(node: KatexParseNode): TexNode {
101
101
  if (right === "\\}") {
102
102
  right = "}";
103
103
  }
104
+ const is_atom = (str:string) => (['(', ')', '[', ']', '{', '}'].includes(str));
104
105
  res.args = [
105
- { type: 'atom', content: left },
106
+ { type: is_atom(left)? 'atom': 'symbol', content: left },
106
107
  body,
107
- { type: 'atom', content: right}
108
+ { type: is_atom(right)? 'atom': 'symbol', content: right}
108
109
  ];
109
110
  break;
110
111
  }
package/src/writer.ts CHANGED
@@ -132,7 +132,7 @@ export class TypstWriter {
132
132
  } else if (node.type === 'leftright') {
133
133
  const [left, body, right] = node.args!;
134
134
  // These pairs will be handled by Typst compiler by default. No need to add lr()
135
- if (["[]", "()", "{}"].includes(left.content + right.content)) {
135
+ if (["[]", "()", "{}", "\\lfloor\\rfloor", "\\lceil\\rceil"].includes(left.content + right.content)) {
136
136
  this.append(left);
137
137
  this.append(body);
138
138
  this.append(right);