Skip to content

Update tidy 5.8.0 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tidyversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.6.0
5.8.0
Binary file modified bin/darwin/tidy
Binary file not shown.
Binary file removed bin/linux32/tidy
Binary file not shown.
Binary file modified bin/linux64/tidy
Binary file not shown.
Binary file removed bin/win32/tidy.exe
Binary file not shown.
Binary file modified bin/win64/tidy.exe
Binary file not shown.
46 changes: 23 additions & 23 deletions htmltidy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function TidyWorker(opts) {
// Store a reference to the merged options for consumption by error reporting logic
var mergedOpts = merge(opts, DEFAULT_OPTS);

this.writable= true;
this.readable= true;
this.writable = true;
this.readable = true;
this._worker = spawn(tidyExec, parseOpts(mergedOpts));
this._worker.stdout.setEncoding('utf8');
var self = this;
Expand All @@ -36,29 +36,29 @@ function TidyWorker(opts) {
self.emit('drain');
});
this._worker.stdin.on('error', function (errors) {
self.emit('error', errors);
});
self.emit('error', errors);
});
this._worker.stdout.on('data', function (data) {
self.emit('data', data);
});
this._worker.stdout.on('close', function (data) {
self.emit('close');
});
this._worker.stderr.on('data', function (data) {
errors+= data;
errors += data;
});
this._worker.on('close', function (code) {
switch(code){
switch (code) {
// If there were any warnings or errors from Tiny command
case TIDY_WARN:
// The user asks to see warnings.
if(mergedOpts.showWarnings){
if (mergedOpts.showWarnings) {
self.emit('error', errors);
}
break;
case TIDY_ERR:
// The user asks to see errors.
if(mergedOpts.showErrors){
if (mergedOpts.showErrors) {
self.emit('error', errors);
}
break;
Expand All @@ -83,14 +83,14 @@ TidyWorker.prototype.end = function (data) {
this._worker.stdin.end(data);
};

TidyWorker.prototype.pause = function () {
TidyWorker.prototype.pause = function () {
if (!this._worker)
throw new Error('worker has been destroyed');
if (this._worker.stdout.pause)
this._worker.stdout.pause();
};

TidyWorker.prototype.resume = function () {
TidyWorker.prototype.resume = function () {
if (!this._worker)
throw new Error('worker has been destroyed');
if (this._worker.stdout.resume)
Expand All @@ -101,7 +101,7 @@ TidyWorker.prototype.destroy = function () {
if (this._worker)
return;
this._worker.kill();
this._worker= null;
this._worker = null;
this.emit('close');
};

Expand All @@ -125,10 +125,10 @@ function tidy(text, opts, cb) {
result += data;
});
worker.on('error', function (data) {
error+= data;
error += data;
});
worker.on('close', function (code) {
setImmediate(function(){cb(error, result);});
setImmediate(function () { cb(error, result); });
});
worker.end(text);
}
Expand All @@ -137,17 +137,17 @@ function chooseExec() {
var tidyExe;
switch (process.platform) {
case 'win32':
if(process.arch == 'x64'){
tidyExe = path.join('win64/','tidy.exe');
if (process.arch == 'x64') {
tidyExe = path.join('win64/', 'tidy.exe');
} else {
tidyExe = path.join('win32/','tidy.exe');
throw new Error('unsupported execution platform');
}
break;
case 'linux':
if(process.arch == 'x64'){
tidyExe = path.join('linux64/','tidy');
if (process.arch == 'x64') {
tidyExe = path.join('linux64/', 'tidy');
} else {
tidyExe = path.join('linux32/','tidy');
throw new Error('unsupported execution platform');
}
break;
case 'darwin':
Expand All @@ -158,9 +158,9 @@ function chooseExec() {
}
tidyExe = path.join(__dirname, 'bin', tidyExe);

var existsSync = fs.existsSync||path.existsSync; // node > 0.6
var existsSync = fs.existsSync || path.existsSync; // node > 0.6
if (!existsSync(tidyExe))
throw new Error('missing tidy executable: ' + tidyExe);
throw new Error('missing tidy executable: ' + tidyExe);
return tidyExe;
}

Expand All @@ -175,7 +175,7 @@ function parseOpts(opts) {
args.push(opts[n]);
break;
case 'boolean':
args.push(opts[n]? 'yes': 'no');
args.push(opts[n] ? 'yes' : 'no');
break;
default:
throw new Error('unknown option type');
Expand All @@ -185,7 +185,7 @@ function parseOpts(opts) {
}

function toHyphens(str) {
return str.replace(/([A-Z])/g, function (m, w) { return '-' + w.toLowerCase(); });
return str.replace(/([A-Z])/g, function (m, w) { return '-' + w.toLowerCase(); });
}

/**
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "htmltidy2",
"version": "0.3.0",
"version": "1.0.0",
"description": "HTML Tidy",
"main": "htmltidy.js",
"scripts": {
Expand All @@ -16,6 +16,9 @@
"url": "https://github.com/c0b41/htmltidy2/issues"
},
"homepage": "https://github.com/c0b41/htmltidy2",
"engines": {
"node": ">= 12 || >= 14 || >= 16"
},
"devDependencies": {
"expect.js": "^0.3.1",
"mocha": "^3.2.0"
Expand Down