blockly-fluid 1.3.12 → 1.3.14
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/index.js +8 -2
- package/package.json +1 -1
- package/utils/dedent.js +18 -9
package/index.js
CHANGED
|
@@ -254,12 +254,18 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
254
254
|
let current = hatBlock.getNextBlock();
|
|
255
255
|
|
|
256
256
|
while (current) {
|
|
257
|
-
code += (
|
|
257
|
+
code += (
|
|
258
|
+
(
|
|
259
|
+
(languageGenerator.forBlock[current.type])
|
|
260
|
+
? languageGenerator.forBlock[current.type](current, languageGenerator)
|
|
261
|
+
: ""
|
|
262
|
+
) + "\n\n"
|
|
263
|
+
);
|
|
258
264
|
|
|
259
265
|
current = current.getNextBlock();
|
|
260
266
|
};
|
|
261
267
|
|
|
262
|
-
return code;
|
|
268
|
+
return code.replace(/\n+$/, "");
|
|
263
269
|
};
|
|
264
270
|
};
|
|
265
271
|
|
package/package.json
CHANGED
package/utils/dedent.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
module.exports = (
|
|
2
|
-
|
|
1
|
+
module.exports = (text) => {
|
|
2
|
+
const lines = text.split("\n");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const firstLine = lines.find((line) => line.trim().length > 0);
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
if (!firstLine) return text;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const indentMatch = firstLine.match(/^[ \t]*/);
|
|
9
|
+
const indentSize = (indentMatch) ? indentMatch[0].length : 0;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
};
|
|
11
|
+
if (indentSize === 0) return text;
|
|
13
12
|
|
|
14
|
-
return
|
|
13
|
+
return (
|
|
14
|
+
lines
|
|
15
|
+
.map((line) => (
|
|
16
|
+
(line.startsWith(" ".repeat(indentSize)))
|
|
17
|
+
? line.slice(indentSize)
|
|
18
|
+
: line
|
|
19
|
+
))
|
|
20
|
+
.join("\n")
|
|
21
|
+
.replace(/^\n/, "")
|
|
22
|
+
.replace(/\n\s*$/, "")
|
|
23
|
+
);
|
|
15
24
|
};
|