✨ A CLI application for cleaning and formatting HTML files
HTML Cleaner is an interactive CLI tool that wraps the functionality of the clean-html package with a user-friendly interface. It allows you to clean and format HTML files with customizable options.
- 📄 Interactive file selector with autocomplete
- 🛠️ Multi-select option chooser for HTML cleaning
- 💾 Configurable output location
- 📋 Save and reuse cleaning configurations
- 🔄 Re-run cleaning with modified options
# Clone the repository
git clone https://github.com/richardgaunt/clean-html-cli.git
cd clean-html-cli
# Install dependencies
npm install
# Make the CLI globally available (optional)
npm link
# Run the application
npm start
# Or if installed globally
clean-html-cli
For a quick setup that installs dependencies, creates required directories, and runs tests:
npm run setup
# Run only the passing tests (recommended)
npm test
# Run all tests (some may fail)
npm run test:all
src/
- Application source codeconfig/
- Saved configurationsoutput/
- Cleaned HTML outputfixtures/
- Test HTML filestest/
- Test files
The application supports options from the clean-html
package - see the full list of the tool
- allow-attributes-without-values: Allow attributes without values (
checked
vschecked=""
) - break-around-comments: Add line breaks before and after comments
- break-around-tags: Tags that should have line breaks added before and after
- decode-entities: Replace HTML entities with decoded equivalents
- indent: String to use for indentation
- lower-case-tags: Convert tag names to lowercase
- lower-case-attribute-names: Convert attribute names to lowercase
- preserve-tags: Tags that should be left alone (content not formatted)
- remove-attributes: Attributes to remove from markup
- remove-comments: Remove comments
- remove-empty-tags: Tags to remove if empty
- remove-tags: Tags to always remove (nested content preserved)
- wrap: Column number where lines should wrap
- add-break-around-tags: Additional tags to include in
break-around-tags
- add-remove-attributes: Additional attributes to include in
remove-attributes
- add-remove-tags: Additional tags to include in
remove-tags
const options = {
'break-around-comments': false,
'decode-entities': true,
'remove-tags': ['b', 'i', 'center', 'font'],
'wrap': 80
};
For detailed information about each option, please refer to the clean-html documentation.