webpipe-js 0.1.10 → 0.1.12

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
@@ -85,7 +85,7 @@ var Parser = class {
85
85
  const text = this.consumeWhile((ch) => ch !== "\n");
86
86
  return {
87
87
  type: "inline",
88
- text: text.trim(),
88
+ text,
89
89
  style: "#",
90
90
  lineNumber: this.getLineNumber(start)
91
91
  };
@@ -95,7 +95,7 @@ var Parser = class {
95
95
  const text = this.consumeWhile((ch) => ch !== "\n");
96
96
  return {
97
97
  type: "inline",
98
- text: text.trim(),
98
+ text,
99
99
  style: "//",
100
100
  lineNumber: this.getLineNumber(start)
101
101
  };
@@ -105,11 +105,12 @@ var Parser = class {
105
105
  parseStandaloneComment() {
106
106
  const start = this.pos;
107
107
  if (this.text.startsWith("#", this.pos)) {
108
+ const originalPos = this.pos;
108
109
  this.pos++;
109
- const text = this.consumeWhile((ch) => ch !== "\n");
110
+ const restOfLine = this.consumeWhile((ch) => ch !== "\n");
110
111
  return {
111
112
  type: "standalone",
112
- text: text.trim(),
113
+ text: restOfLine,
113
114
  style: "#",
114
115
  lineNumber: this.getLineNumber(start)
115
116
  };
@@ -119,7 +120,7 @@ var Parser = class {
119
120
  const text = this.consumeWhile((ch) => ch !== "\n");
120
121
  return {
121
122
  type: "standalone",
122
- text: text.trim(),
123
+ text,
123
124
  style: "//",
124
125
  lineNumber: this.getLineNumber(start)
125
126
  };
@@ -735,6 +736,12 @@ function printTest(test) {
735
736
  return lines.join("\n");
736
737
  }
737
738
  function printComment(comment) {
739
+ if (comment.style === "#" && comment.text.startsWith("#")) {
740
+ return `${comment.style}${comment.text}`;
741
+ }
742
+ if (comment.text === "" || comment.text.startsWith(" ")) {
743
+ return `${comment.style}${comment.text}`;
744
+ }
738
745
  return `${comment.style} ${comment.text}`;
739
746
  }
740
747
  function printDescribe(describe) {
@@ -779,12 +786,7 @@ function prettyPrint(program) {
779
786
  allItems.push({ type: "comment", item: comment, lineNumber: comment.lineNumber || 0 });
780
787
  });
781
788
  allItems.sort((a, b) => a.lineNumber - b.lineNumber);
782
- let hasConfigs = false;
783
789
  allItems.forEach((entry, index) => {
784
- if (entry.type === "config" && !hasConfigs) {
785
- lines.push("## Config");
786
- hasConfigs = true;
787
- }
788
790
  switch (entry.type) {
789
791
  case "comment":
790
792
  lines.push(printComment(entry.item));
@@ -812,7 +814,7 @@ function prettyPrint(program) {
812
814
  break;
813
815
  }
814
816
  });
815
- return lines.join("\n").trim();
817
+ return lines.join("\n").trim() + "\n";
816
818
  }
817
819
  function formatConfigValue(value) {
818
820
  switch (value.kind) {
package/dist/index.mjs CHANGED
@@ -41,7 +41,7 @@ var Parser = class {
41
41
  const text = this.consumeWhile((ch) => ch !== "\n");
42
42
  return {
43
43
  type: "inline",
44
- text: text.trim(),
44
+ text,
45
45
  style: "#",
46
46
  lineNumber: this.getLineNumber(start)
47
47
  };
@@ -51,7 +51,7 @@ var Parser = class {
51
51
  const text = this.consumeWhile((ch) => ch !== "\n");
52
52
  return {
53
53
  type: "inline",
54
- text: text.trim(),
54
+ text,
55
55
  style: "//",
56
56
  lineNumber: this.getLineNumber(start)
57
57
  };
@@ -61,11 +61,12 @@ var Parser = class {
61
61
  parseStandaloneComment() {
62
62
  const start = this.pos;
63
63
  if (this.text.startsWith("#", this.pos)) {
64
+ const originalPos = this.pos;
64
65
  this.pos++;
65
- const text = this.consumeWhile((ch) => ch !== "\n");
66
+ const restOfLine = this.consumeWhile((ch) => ch !== "\n");
66
67
  return {
67
68
  type: "standalone",
68
- text: text.trim(),
69
+ text: restOfLine,
69
70
  style: "#",
70
71
  lineNumber: this.getLineNumber(start)
71
72
  };
@@ -75,7 +76,7 @@ var Parser = class {
75
76
  const text = this.consumeWhile((ch) => ch !== "\n");
76
77
  return {
77
78
  type: "standalone",
78
- text: text.trim(),
79
+ text,
79
80
  style: "//",
80
81
  lineNumber: this.getLineNumber(start)
81
82
  };
@@ -691,6 +692,12 @@ function printTest(test) {
691
692
  return lines.join("\n");
692
693
  }
693
694
  function printComment(comment) {
695
+ if (comment.style === "#" && comment.text.startsWith("#")) {
696
+ return `${comment.style}${comment.text}`;
697
+ }
698
+ if (comment.text === "" || comment.text.startsWith(" ")) {
699
+ return `${comment.style}${comment.text}`;
700
+ }
694
701
  return `${comment.style} ${comment.text}`;
695
702
  }
696
703
  function printDescribe(describe) {
@@ -735,12 +742,7 @@ function prettyPrint(program) {
735
742
  allItems.push({ type: "comment", item: comment, lineNumber: comment.lineNumber || 0 });
736
743
  });
737
744
  allItems.sort((a, b) => a.lineNumber - b.lineNumber);
738
- let hasConfigs = false;
739
745
  allItems.forEach((entry, index) => {
740
- if (entry.type === "config" && !hasConfigs) {
741
- lines.push("## Config");
742
- hasConfigs = true;
743
- }
744
746
  switch (entry.type) {
745
747
  case "comment":
746
748
  lines.push(printComment(entry.item));
@@ -768,7 +770,7 @@ function prettyPrint(program) {
768
770
  break;
769
771
  }
770
772
  });
771
- return lines.join("\n").trim();
773
+ return lines.join("\n").trim() + "\n";
772
774
  }
773
775
  function formatConfigValue(value) {
774
776
  switch (value.kind) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",