autosnippet 1.2.13 → 1.2.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/README.md +2 -2
- package/bin/install.js +30 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
[[ASUIKitAlertToast sharedInstance] alertWithMessage:@"<#object#>"];
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
模块被工程引入时,业务开发者可以在
|
|
20
|
+
模块被工程引入时,业务开发者可以在Xcode里,敲击`@toast`来获取这段标准的使用代码
|
|
21
21
|
|
|
22
|
-
Toast
|
|
22
|
+
Toast模块添加配置时可以选择分类,使用者可以通过`@view`或者`@tool`联想出同类别模块列表
|
|
23
23
|
|
|
24
24
|
代码量大的UI模块,能一键获取全部标准代码
|
|
25
25
|
|
package/bin/install.js
CHANGED
|
@@ -74,8 +74,9 @@ function writeSingleSnippet(snippet, template) {
|
|
|
74
74
|
let turnValue = '';
|
|
75
75
|
|
|
76
76
|
for (var index = 0; index < value.length; index++) {
|
|
77
|
-
// ✅
|
|
78
|
-
const
|
|
77
|
+
// ✅ 先解码 HTML 实体(JSON 中可能已转义),再转义写入 XML
|
|
78
|
+
const unescapedLine = unescapeString(value[index]);
|
|
79
|
+
const escapedLine = escapeString(unescapedLine);
|
|
79
80
|
if (index === 0) {
|
|
80
81
|
turnValue += escapedLine + '\n';
|
|
81
82
|
} else {
|
|
@@ -84,8 +85,8 @@ function writeSingleSnippet(snippet, template) {
|
|
|
84
85
|
}
|
|
85
86
|
value = turnValue;
|
|
86
87
|
} else {
|
|
87
|
-
// ✅
|
|
88
|
-
value = escapeString(value);
|
|
88
|
+
// ✅ 先解码 HTML 实体(JSON 中可能已转义),再转义写入 XML
|
|
89
|
+
value = escapeString(unescapeString(value));
|
|
89
90
|
}
|
|
90
91
|
tempVal = '\t<string>' + value + '</string>\n';
|
|
91
92
|
}
|
|
@@ -216,8 +217,9 @@ function addCodeSnippets(specFile, singleSnippet) {
|
|
|
216
217
|
let turnValue = '';
|
|
217
218
|
|
|
218
219
|
for (var index = 0; index < value.length; index++) {
|
|
219
|
-
// ✅
|
|
220
|
-
const
|
|
220
|
+
// ✅ 先解码 HTML 实体(JSON 中可能已转义),再转义写入 XML
|
|
221
|
+
const unescapedLine = unescapeString(value[index]);
|
|
222
|
+
const escapedLine = escapeString(unescapedLine);
|
|
221
223
|
if (index === 0) {
|
|
222
224
|
turnValue += escapedLine + '\n';
|
|
223
225
|
} else {
|
|
@@ -226,8 +228,8 @@ function addCodeSnippets(specFile, singleSnippet) {
|
|
|
226
228
|
}
|
|
227
229
|
value = turnValue;
|
|
228
230
|
} else {
|
|
229
|
-
// ✅
|
|
230
|
-
value = escapeString(value);
|
|
231
|
+
// ✅ 先解码 HTML 实体(JSON 中可能已转义),再转义写入 XML
|
|
232
|
+
value = escapeString(unescapeString(value));
|
|
231
233
|
}
|
|
232
234
|
tempVal = '\t<string>' + value + '</string>\n';
|
|
233
235
|
}
|
|
@@ -261,7 +263,27 @@ function addCodeSnippets(specFile, singleSnippet) {
|
|
|
261
263
|
return { success: false, error: '配置文件格式错误' };
|
|
262
264
|
}
|
|
263
265
|
|
|
266
|
+
/**
|
|
267
|
+
* 解码 HTML 实体(将 & < > 转回原始字符)
|
|
268
|
+
*/
|
|
269
|
+
function unescapeString(string) {
|
|
270
|
+
if (typeof string !== 'string') {
|
|
271
|
+
return string;
|
|
272
|
+
}
|
|
273
|
+
// 必须先解码 &,否则会把 &lt; 错误解码
|
|
274
|
+
string = string.replace(/&/g, '&');
|
|
275
|
+
string = string.replace(/</g, '<');
|
|
276
|
+
string = string.replace(/>/g, '>');
|
|
277
|
+
return string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 转义特殊字符(将 & < > 转为 HTML 实体)
|
|
282
|
+
*/
|
|
264
283
|
function escapeString(string) {
|
|
284
|
+
if (typeof string !== 'string') {
|
|
285
|
+
return string;
|
|
286
|
+
}
|
|
265
287
|
// 必须先转义 &,否则会把 < 转成 &lt;
|
|
266
288
|
string = string.replace(/&/g, '&');
|
|
267
289
|
string = string.replace(/</g, '<');
|