mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Removed tidy html. (#6039)
This commit is contained in:
parent
8d014fb7e9
commit
d5fc948705
7 changed files with 0 additions and 132 deletions
|
@ -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?
|
||||
*/
|
||||
|
|
|
@ -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}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue