Removed tidy html. (#6039)

This commit is contained in:
SamTV12345 2023-11-15 19:27:34 +01:00 committed by GitHub
parent 8d014fb7e9
commit d5fc948705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 132 deletions

View file

@ -260,11 +260,6 @@ exports.abiword = null;
*/
exports.soffice = null;
/**
* The path of the tidy executable
*/
exports.tidyHtml = null;
/**
* Should we support none natively supported file types on import?
*/

View file

@ -1,43 +0,0 @@
'use strict';
/**
* Tidy up the HTML in a given file
*/
const log4js = require('log4js');
const settings = require('./Settings');
const spawn = require('child_process').spawn;
exports.tidy = (srcFile) => {
const logger = log4js.getLogger('TidyHtml');
return new Promise((resolve, reject) => {
// Don't do anything if Tidy hasn't been enabled
if (!settings.tidyHtml) {
logger.debug('tidyHtml has not been configured yet, ignoring tidy request');
return resolve(null);
}
let errMessage = '';
// Spawn a new tidy instance that cleans up the file inline
logger.debug(`Tidying ${srcFile}`);
const tidy = spawn(settings.tidyHtml, ['-modify', srcFile]);
// Keep track of any error messages
tidy.stderr.on('data', (data) => {
errMessage += data.toString();
});
tidy.on('close', (code) => {
// Tidy returns a 0 when no errors occur and a 1 exit code when
// the file could be tidied but a few warnings were generated
if (code === 0 || code === 1) {
logger.debug(`Tidied ${srcFile} successfully`);
resolve(null);
} else {
logger.error(`Failed to tidy ${srcFile}\n${errMessage}`);
reject(`Tidy died with exit code ${code}`);
}
});
});
};