webpipe-js 2.0.20 → 2.0.21

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/index.cjs CHANGED
@@ -367,7 +367,7 @@ var Parser = class {
367
367
  if (this.cur() === ")") {
368
368
  throw new ParseFailure("empty tag arguments not allowed", this.pos);
369
369
  }
370
- args.push(this.parseIdentifier());
370
+ args.push(this.parseTagArgument());
371
371
  this.skipInlineSpaces();
372
372
  while (this.cur() === ",") {
373
373
  this.pos++;
@@ -375,12 +375,17 @@ var Parser = class {
375
375
  if (this.cur() === ")") {
376
376
  throw new ParseFailure("trailing comma in tag arguments", this.pos);
377
377
  }
378
- args.push(this.parseIdentifier());
378
+ args.push(this.parseTagArgument());
379
379
  this.skipInlineSpaces();
380
380
  }
381
381
  this.expect(")");
382
382
  return args;
383
383
  }
384
+ parseTagArgument() {
385
+ const bt = this.tryParse(() => this.parseBacktickString());
386
+ if (bt !== null) return bt;
387
+ return this.parseIdentifier();
388
+ }
384
389
  parseTags() {
385
390
  const tags = [];
386
391
  while (!this.eof()) {
@@ -1406,7 +1411,13 @@ function formatTags(tags) {
1406
1411
  }
1407
1412
  function formatTag(tag) {
1408
1413
  const negation = tag.negated ? "!" : "";
1409
- const args = tag.args.length > 0 ? `(${tag.args.join(",")})` : "";
1414
+ const formattedArgs = tag.args.map((arg) => {
1415
+ if (/[^a-zA-Z0-9_-]/.test(arg)) {
1416
+ return `\`${arg}\``;
1417
+ }
1418
+ return arg;
1419
+ });
1420
+ const args = tag.args.length > 0 ? `(${formattedArgs.join(",")})` : "";
1410
1421
  return `@${negation}${tag.name}${args}`;
1411
1422
  }
1412
1423
  function formatTagExpr(expr) {
package/dist/index.mjs CHANGED
@@ -317,7 +317,7 @@ var Parser = class {
317
317
  if (this.cur() === ")") {
318
318
  throw new ParseFailure("empty tag arguments not allowed", this.pos);
319
319
  }
320
- args.push(this.parseIdentifier());
320
+ args.push(this.parseTagArgument());
321
321
  this.skipInlineSpaces();
322
322
  while (this.cur() === ",") {
323
323
  this.pos++;
@@ -325,12 +325,17 @@ var Parser = class {
325
325
  if (this.cur() === ")") {
326
326
  throw new ParseFailure("trailing comma in tag arguments", this.pos);
327
327
  }
328
- args.push(this.parseIdentifier());
328
+ args.push(this.parseTagArgument());
329
329
  this.skipInlineSpaces();
330
330
  }
331
331
  this.expect(")");
332
332
  return args;
333
333
  }
334
+ parseTagArgument() {
335
+ const bt = this.tryParse(() => this.parseBacktickString());
336
+ if (bt !== null) return bt;
337
+ return this.parseIdentifier();
338
+ }
334
339
  parseTags() {
335
340
  const tags = [];
336
341
  while (!this.eof()) {
@@ -1356,7 +1361,13 @@ function formatTags(tags) {
1356
1361
  }
1357
1362
  function formatTag(tag) {
1358
1363
  const negation = tag.negated ? "!" : "";
1359
- const args = tag.args.length > 0 ? `(${tag.args.join(",")})` : "";
1364
+ const formattedArgs = tag.args.map((arg) => {
1365
+ if (/[^a-zA-Z0-9_-]/.test(arg)) {
1366
+ return `\`${arg}\``;
1367
+ }
1368
+ return arg;
1369
+ });
1370
+ const args = tag.args.length > 0 ? `(${formattedArgs.join(",")})` : "";
1360
1371
  return `@${negation}${tag.name}${args}`;
1361
1372
  }
1362
1373
  function formatTagExpr(expr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",