@appthreat/atom-parsetools 1.1.1 → 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
@@ -267,43 +267,53 @@ const toEjsAst = (file) => {
267
267
  const openLen = match[1].length;
268
268
  arr[openStart] = "<";
269
269
  arr[openStart + 1] = "%";
270
- for (let i = 2; i < openLen; i++) {
271
- arr[openStart + i] = " ";
272
- }
270
+ for (let i = 2; i < openLen; i++) arr[openStart + i] = " ";
273
271
  const closeStart = match.index + match[0].length - match[3].length;
274
272
  const closeLen = match[3].length;
275
273
  arr[closeStart] = "%";
276
274
  arr[closeStart + 1] = ">";
277
- for (let i = 2; i < closeLen; i++) {
278
- arr[closeStart + i] = " ";
279
- }
275
+ for (let i = 2; i < closeLen; i++) arr[closeStart + i] = " ";
280
276
  const content = match[2];
281
277
  const contentOffset = openStart + openLen;
282
278
  const innerRegex = /(<%[=\-_#]?)([\s\S]*?)([-_#]?%>)/g;
283
279
  let innerMatch;
284
280
  while ((innerMatch = innerRegex.exec(content)) !== null) {
285
281
  const innerAbsStart = contentOffset + innerMatch.index;
286
- for (let k = 0; k < innerMatch[0].length; k++) {
287
- arr[innerAbsStart + k] = " ";
282
+ if (innerMatch[1] === "<%" && innerMatch[3] === "-%>") {
283
+ for (let k = 0; k < innerMatch[0].length; k++)
284
+ arr[innerAbsStart + k] = " ";
285
+ } else {
286
+ for (let k = 0; k < innerMatch[1].length; k++)
287
+ arr[innerAbsStart + k] = " ";
288
+ const endDelimStart =
289
+ innerAbsStart + innerMatch[0].length - innerMatch[3].length;
290
+ for (let k = 0; k < innerMatch[3].length; k++)
291
+ arr[endDelimStart + k] = " ";
288
292
  }
289
293
  }
290
294
  }
295
+
291
296
  const codeWithoutScriptTag = arr.join("");
292
297
  const out = new Array(codeWithoutScriptTag.length).fill(" ");
293
298
  for (let i = 0; i < codeWithoutScriptTag.length; i++) {
294
299
  const c = codeWithoutScriptTag[i];
295
300
  if (c === "\n" || c === "\r") out[i] = c;
296
301
  }
302
+
297
303
  const tagRegex = /(<%[=\-_#]?)([\s\S]*?)([-_#]?%>)/g;
298
304
  let tagMatch;
299
305
  while ((tagMatch = tagRegex.exec(codeWithoutScriptTag)) !== null) {
300
306
  const [fullMatch, openTag, content, closeTag] = tagMatch;
301
307
  if (openTag === "<%#" || content.trim().startsWith("include ")) continue;
308
+
302
309
  let processedContent = content.trim();
310
+ let isTransformed = false;
303
311
  if (processedContent === "end") {
304
312
  processedContent = "}";
313
+ isTransformed = true;
305
314
  } else if (processedContent === "else") {
306
315
  processedContent = "} else {";
316
+ isTransformed = true;
307
317
  } else if (processedContent.startsWith("else if")) {
308
318
  let sub = processedContent.substring(4).trim();
309
319
  const controlMatch = sub.match(/^(if)\s+(?!\()(.+)$/);
@@ -311,6 +321,7 @@ const toEjsAst = (file) => {
311
321
  sub = `if (${controlMatch[2]})`;
312
322
  }
313
323
  processedContent = `} else ${sub} {`;
324
+ isTransformed = true;
314
325
  } else {
315
326
  const controlMatch = processedContent.match(
316
327
  /^(if|while|for)\s+(?!\()(.+)$/
@@ -319,6 +330,7 @@ const toEjsAst = (file) => {
319
330
  const keyword = controlMatch[1];
320
331
  const condition = controlMatch[2];
321
332
  processedContent = `${keyword} (${condition})`;
333
+ isTransformed = true;
322
334
  }
323
335
  if (
324
336
  /^(if|while|for|try|switch|catch)/.test(processedContent) &&
@@ -327,21 +339,40 @@ const toEjsAst = (file) => {
327
339
  !processedContent.endsWith(";")
328
340
  ) {
329
341
  processedContent += " {";
342
+ isTransformed = true;
330
343
  }
331
344
  }
332
- const needsSemi =
333
- processedContent.length > 0 &&
334
- !processedContent.endsWith("{") &&
335
- !processedContent.endsWith("}") &&
336
- !processedContent.endsWith(";");
337
- if (needsSemi) {
338
- processedContent += ";";
339
- }
340
- const startIndex = tagMatch.index;
341
- const maxLen = fullMatch.length;
342
- for (let k = 0; k < processedContent.length; k++) {
343
- if (k < maxLen) {
344
- out[startIndex + k] = processedContent[k];
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] = ";";
345
376
  }
346
377
  }
347
378
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appthreat/atom-parsetools",
3
- "version": "1.1.1",
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.1',
5
- 'version' => '1.1.1.0',
6
- 'reference' => 'f6576535af9e41e44bbfaf278b32edc0dfbaef01',
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.1',
15
- 'version' => '1.1.1.0',
16
- 'reference' => 'f6576535af9e41e44bbfaf278b32edc0dfbaef01',
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.20260105-2215-ju1bl3 sitelibdir\=./.gem.20260105-2215-ju1bl3 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.20260105-2215-ju1bl3 sitelibdir\=./.gem.20260105-2215-ju1bl3
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.20260105-2215-ju1bl3 sitelibdir\=./.gem.20260105-2215-ju1bl3 install
41
- /usr/bin/install -c -m 0755 prism.so ./.gem.20260105-2215-ju1bl3/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.20260105-2215-ju1bl3 sitelibdir\=./.gem.20260105-2215-ju1bl3 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.20260105-2215-74o4o6 sitelibdir\=./.gem.20260105-2215-74o4o6 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.20260105-2215-74o4o6 sitelibdir\=./.gem.20260105-2215-74o4o6
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.20260105-2215-74o4o6 sitelibdir\=./.gem.20260105-2215-74o4o6 install
15
- /usr/bin/install -c -m 0755 cparse.so ./.gem.20260105-2215-74o4o6/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.20260105-2215-74o4o6 sitelibdir\=./.gem.20260105-2215-74o4o6 clean
18
+ make DESTDIR\= sitearchdir\=./.gem.20260106-2204-4787mi sitelibdir\=./.gem.20260106-2204-4787mi clean