Skip to content

Commit 68d66b1

Browse files
committed
chore: publish v0.0.4
1 parent 2e46b23 commit 68d66b1

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

dist/index.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class WXMLParser {
2828
return this.inputs[this.pos];
2929
}
3030

31+
getNextString(len) {
32+
return this.inputs.substr(this.pos, len)
33+
}
34+
3135
startWiths(str) {
3236
return this.inputs.substr(this.pos, str.length) === str;
3337
}
@@ -42,9 +46,18 @@ class WXMLParser {
4246
return this.inputs[this.pos++];
4347
}
4448

45-
consumeWhile(matchFunc) {
49+
consumeCharIgnoreWhitespace() {
50+
const text = this.consumeWhitespace()
51+
// if (text) {
52+
// handlerCompany.call(this, 'text', text);
53+
// }
54+
return this.inputs[this.pos++];
55+
}
56+
57+
consumeWhile(matchFunc, len) {
4658
let result = '';
47-
while (!this.isEOF() && matchFunc(this.getNextChar())) {
59+
60+
while (!this.isEOF() && matchFunc(len ? this.getNextString(len) : this.getNextChar())) {
4861
result += this.consumeChar();
4962
}
5063
return result;
@@ -129,17 +142,17 @@ class WXMLParser {
129142
}
130143

131144
if (tagName === 'wxs') {
132-
const wxs = this.consumeWhile(char => char !== '<');
145+
const wxs = this.consumeWhile(str => str !== '</wxs', 5);
133146
handlerCompany.call(this, 'wxs', wxs);
134147
} else {
135148
this.parseNodes();
136149
}
137150

138-
assert.ok(this.consumeChar() === '<');
139-
assert.ok(this.consumeChar() === '/');
151+
assert.ok(this.consumeCharIgnoreWhitespace() === '<');
152+
assert.ok(this.consumeCharIgnoreWhitespace() === '/');
140153
let closeTagName = this.parseTagName();
141154
handlerCompany.call(this, 'closetag', closeTagName, false);
142-
assert.ok(this.consumeChar() === '>');
155+
assert.ok(this.consumeCharIgnoreWhitespace() === '>');
143156
}
144157

145158
parseTagName() {
@@ -216,7 +229,6 @@ let minifier = function(source, options) {
216229
str += `</${tagname}>`;
217230
},
218231
onwxs(wxs) {
219-
console.log(wxs);
220232
str += wxs;
221233
}
222234
});

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wxml-minifier",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "微信小程序WXML压缩工具",
55
"main": "dist/index.js",
66
"scripts": {
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/LeeJim/wxml-minifier#readme",
2727
"dependencies": {
28-
"@leejim/wxml-parser": "^0.1.2"
28+
"@leejim/wxml-parser": "^0.1.5"
2929
},
3030
"devDependencies": {
3131
"@vercel/ncc": "^0.33.1",

0 commit comments

Comments
 (0)