@appthreat/atom-parsetools 1.1.0 → 1.1.2

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/astgen.js CHANGED
@@ -262,7 +262,6 @@ const toEjsAst = (file) => {
262
262
  let arr = originalCode.split("");
263
263
  const scriptRegex = /(<script>)([\s\S]*?)(<\/script>)/gi;
264
264
  let match;
265
-
266
265
  while ((match = scriptRegex.exec(originalCode)) !== null) {
267
266
  const openStart = match.index;
268
267
  const openLen = match[1].length;
@@ -293,6 +292,7 @@ const toEjsAst = (file) => {
293
292
  }
294
293
  }
295
294
  }
295
+
296
296
  const codeWithoutScriptTag = arr.join("");
297
297
  const out = new Array(codeWithoutScriptTag.length).fill(" ");
298
298
  for (let i = 0; i < codeWithoutScriptTag.length; i++) {
@@ -305,20 +305,75 @@ const toEjsAst = (file) => {
305
305
  while ((tagMatch = tagRegex.exec(codeWithoutScriptTag)) !== null) {
306
306
  const [fullMatch, openTag, content, closeTag] = tagMatch;
307
307
  if (openTag === "<%#" || content.trim().startsWith("include ")) continue;
308
- const startIndex = tagMatch.index + openTag.length;
309
- const endIndex = tagMatch.index + fullMatch.length - closeTag.length;
310
- for (let k = startIndex; k < endIndex; k++) {
311
- out[k] = codeWithoutScriptTag[k];
308
+
309
+ let processedContent = content.trim();
310
+ let isTransformed = false;
311
+ if (processedContent === "end") {
312
+ processedContent = "}";
313
+ isTransformed = true;
314
+ } else if (processedContent === "else") {
315
+ processedContent = "} else {";
316
+ isTransformed = true;
317
+ } else if (processedContent.startsWith("else if")) {
318
+ let sub = processedContent.substring(4).trim();
319
+ const controlMatch = sub.match(/^(if)\s+(?!\()(.+)$/);
320
+ if (controlMatch) {
321
+ sub = `if (${controlMatch[2]})`;
322
+ }
323
+ processedContent = `} else ${sub} {`;
324
+ isTransformed = true;
325
+ } else {
326
+ const controlMatch = processedContent.match(
327
+ /^(if|while|for)\s+(?!\()(.+)$/
328
+ );
329
+ if (controlMatch) {
330
+ const keyword = controlMatch[1];
331
+ const condition = controlMatch[2];
332
+ processedContent = `${keyword} (${condition})`;
333
+ isTransformed = true;
334
+ }
335
+ if (
336
+ /^(if|while|for|try|switch|catch)/.test(processedContent) &&
337
+ !processedContent.endsWith("{") &&
338
+ !processedContent.endsWith("}") &&
339
+ !processedContent.endsWith(";")
340
+ ) {
341
+ processedContent += " {";
342
+ isTransformed = true;
343
+ }
312
344
  }
313
- const trimmed = content.trim();
314
- const needsSemi =
315
- trimmed.length > 0 &&
316
- !trimmed.endsWith("{") &&
317
- !trimmed.endsWith("}") &&
318
- !trimmed.endsWith(";");
319
-
320
- if (needsSemi) {
321
- out[endIndex] = ";";
345
+ if (isTransformed) {
346
+ const startIndex = tagMatch.index;
347
+ const maxLen = fullMatch.length;
348
+ const needsSemi =
349
+ processedContent.length > 0 &&
350
+ !processedContent.endsWith("{") &&
351
+ !processedContent.endsWith("}") &&
352
+ !processedContent.endsWith(";");
353
+ if (needsSemi) processedContent += ";";
354
+
355
+ for (let k = 0; k < processedContent.length; k++) {
356
+ if (k < maxLen) {
357
+ out[startIndex + k] = processedContent[k];
358
+ }
359
+ }
360
+ } else {
361
+ const startIndex = tagMatch.index + openTag.length;
362
+ const endIndex = tagMatch.index + fullMatch.length - closeTag.length;
363
+
364
+ for (let k = startIndex; k < endIndex; k++) {
365
+ out[k] = codeWithoutScriptTag[k];
366
+ }
367
+
368
+ const needsSemi =
369
+ processedContent.length > 0 &&
370
+ !processedContent.endsWith("{") &&
371
+ !processedContent.endsWith("}") &&
372
+ !processedContent.endsWith(";");
373
+
374
+ if (needsSemi) {
375
+ out[endIndex] = ";";
376
+ }
322
377
  }
323
378
  }
324
379
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appthreat/atom-parsetools",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Parsing tools that complement the @appthreat/atom project.",
5
5
  "main": "./index.js",
6
6
  "type": "module",
@@ -1,9 +1,9 @@
1
1
  <?php return array(
2
2
  'root' => array(
3
3
  'name' => '__root__',
4
- 'pretty_version' => 'v1.1.0',
5
- 'version' => '1.1.0.0',
6
- 'reference' => '4684ed7a0f1aabea558c1198b039f1d6d2d1022c',
4
+ 'pretty_version' => 'v1.1.2',
5
+ 'version' => '1.1.2.0',
6
+ 'reference' => 'ea69d1c066e3a4d62a23e93dcb74e93379a38151',
7
7
  'type' => 'library',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -11,9 +11,9 @@
11
11
  ),
12
12
  'versions' => array(
13
13
  '__root__' => array(
14
- 'pretty_version' => 'v1.1.0',
15
- 'version' => '1.1.0.0',
16
- 'reference' => '4684ed7a0f1aabea558c1198b039f1d6d2d1022c',
14
+ 'pretty_version' => 'v1.1.2',
15
+ 'version' => '1.1.2.0',
16
+ 'reference' => 'ea69d1c066e3a4d62a23e93dcb74e93379a38151',
17
17
  'type' => 'library',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),
@@ -6,10 +6,10 @@ checking for whether -fvisibility=hidden is accepted as CFLAGS... yes
6
6
  creating Makefile
7
7
 
8
8
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.7.0/ext/prism
9
- make -j5 DESTDIR\= sitearchdir\=./.gem.20251228-2256-x6mrnn sitelibdir\=./.gem.20251228-2256-x6mrnn clean
9
+ make -j5 DESTDIR\= sitearchdir\=./.gem.20260106-2204-t77tu9 sitelibdir\=./.gem.20260106-2204-t77tu9 clean
10
10
 
11
11
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.7.0/ext/prism
12
- make -j5 DESTDIR\= sitearchdir\=./.gem.20251228-2256-x6mrnn sitelibdir\=./.gem.20251228-2256-x6mrnn
12
+ make -j5 DESTDIR\= sitearchdir\=./.gem.20260106-2204-t77tu9 sitelibdir\=./.gem.20260106-2204-t77tu9
13
13
  compiling api_node.c
14
14
  compiling api_pack.c
15
15
  compiling extension.c
@@ -37,8 +37,8 @@ compiling ./../../src/util/pm_strpbrk.c
37
37
  linking shared-object prism/prism.so
38
38
 
39
39
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.7.0/ext/prism
40
- make -j5 DESTDIR\= sitearchdir\=./.gem.20251228-2256-x6mrnn sitelibdir\=./.gem.20251228-2256-x6mrnn install
41
- /usr/bin/install -c -m 0755 prism.so ./.gem.20251228-2256-x6mrnn/prism
40
+ make -j5 DESTDIR\= sitearchdir\=./.gem.20260106-2204-t77tu9 sitelibdir\=./.gem.20260106-2204-t77tu9 install
41
+ /usr/bin/install -c -m 0755 prism.so ./.gem.20260106-2204-t77tu9/prism
42
42
 
43
43
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.7.0/ext/prism
44
- make DESTDIR\= sitearchdir\=./.gem.20251228-2256-x6mrnn sitelibdir\=./.gem.20251228-2256-x6mrnn clean
44
+ make DESTDIR\= sitearchdir\=./.gem.20260106-2204-t77tu9 sitelibdir\=./.gem.20260106-2204-t77tu9 clean
@@ -3,16 +3,16 @@ current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rub
3
3
  creating Makefile
4
4
 
5
5
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse
6
- make -j5 DESTDIR\= sitearchdir\=./.gem.20251228-2256-thfbzl sitelibdir\=./.gem.20251228-2256-thfbzl clean
6
+ make -j5 DESTDIR\= sitearchdir\=./.gem.20260106-2204-4787mi sitelibdir\=./.gem.20260106-2204-4787mi clean
7
7
 
8
8
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse
9
- make -j5 DESTDIR\= sitearchdir\=./.gem.20251228-2256-thfbzl sitelibdir\=./.gem.20251228-2256-thfbzl
9
+ make -j5 DESTDIR\= sitearchdir\=./.gem.20260106-2204-4787mi sitelibdir\=./.gem.20260106-2204-4787mi
10
10
  compiling cparse.c
11
11
  linking shared-object racc/cparse.so
12
12
 
13
13
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse
14
- make -j5 DESTDIR\= sitearchdir\=./.gem.20251228-2256-thfbzl sitelibdir\=./.gem.20251228-2256-thfbzl install
15
- /usr/bin/install -c -m 0755 cparse.so ./.gem.20251228-2256-thfbzl/racc
14
+ make -j5 DESTDIR\= sitearchdir\=./.gem.20260106-2204-4787mi sitelibdir\=./.gem.20260106-2204-4787mi install
15
+ /usr/bin/install -c -m 0755 cparse.so ./.gem.20260106-2204-4787mi/racc
16
16
 
17
17
  current directory: /home/runner/work/atom-parsetools/atom-parsetools/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse
18
- make DESTDIR\= sitearchdir\=./.gem.20251228-2256-thfbzl sitelibdir\=./.gem.20251228-2256-thfbzl clean
18
+ make DESTDIR\= sitearchdir\=./.gem.20260106-2204-4787mi sitelibdir\=./.gem.20260106-2204-4787mi clean