We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b81abb3 commit f3d5484Copy full SHA for f3d5484
docs/_util.js
@@ -0,0 +1,28 @@
1
+function stripIndent (rawString) {
2
+ const match = rawString.match(/^[ \t]*(?=\S)/gm);
3
+
4
+ if (!match) {
5
+ return rawString;
6
+ }
7
8
+ const minIndent = Math.min.apply(Math, match.map(x => x.length));
9
10
+ const reMinIndent = new RegExp(`^[ \\t]{${minIndent}}`, 'gm');
11
12
+ let strReindented = rawString;
13
+ if (minIndent > 0) {
14
+ strReindented = rawString.replace(reMinIndent, '');
15
16
17
+ return strReindented.trim();
18
+}//stripIndent()
19
20
+function snippet (raw) {
21
+ // https://regex101.com/r/hKMzZP/4
22
+ let normalized = raw.replace(/(\s+^\s+$|\s+(?=>))/gm, '');
23
+ return stripIndent(normalized);
24
+}
25
26
+export default {
27
+ snippet,
28
+};
0 commit comments