{"id":18389599,"url":"https://github.com/anseki/grunt-htmlclean","last_synced_at":"2025-06-30T21:34:42.013Z","repository":{"id":10286910,"uuid":"12404652","full_name":"anseki/grunt-htmlclean","owner":"anseki","description":"Simple and safety HTML/SVG cleaner to minify without changing its structure.","archived":false,"fork":false,"pushed_at":"2024-06-17T01:52:46.000Z","size":206,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-22T16:03:43.618Z","etag":null,"topics":["clean","comment","compress","grunt","grunt-plugins","gruntplugin","html","javascript","lightweight","linebreak","minify","svg","unneeded-whitespaces","whitespace"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anseki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-27T11:51:09.000Z","updated_at":"2024-06-17T01:52:14.000Z","dependencies_parsed_at":"2024-06-18T22:43:06.159Z","dependency_job_id":"5dcc223a-cdb1-4a61-ba29-735eed985cfb","html_url":"https://github.com/anseki/grunt-htmlclean","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/anseki/grunt-htmlclean","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fgrunt-htmlclean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fgrunt-htmlclean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fgrunt-htmlclean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fgrunt-htmlclean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anseki","download_url":"https://codeload.github.com/anseki/grunt-htmlclean/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fgrunt-htmlclean/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262189264,"owners_count":23272542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean","comment","compress","grunt","grunt-plugins","gruntplugin","html","javascript","lightweight","linebreak","minify","svg","unneeded-whitespaces","whitespace"],"created_at":"2024-11-06T01:43:54.892Z","updated_at":"2025-06-30T21:34:41.945Z","avatar_url":"https://github.com/anseki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-htmlclean\n\n[![npm](https://img.shields.io/npm/v/grunt-htmlclean.svg)](https://www.npmjs.com/package/grunt-htmlclean) [![GitHub issues](https://img.shields.io/github/issues/anseki/grunt-htmlclean.svg)](https://github.com/anseki/grunt-htmlclean/issues) [![David](https://img.shields.io/david/anseki/grunt-htmlclean.svg)](package.json) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nThis [Grunt](http://gruntjs.com/) plugin is wrapper of [htmlclean](https://github.com/anseki/htmlclean).\n\n* [gulp](http://gulpjs.com/) plugin: [gulp-htmlclean](https://github.com/anseki/gulp-htmlclean)\n* [webpack](https://webpack.js.org/) loader: [htmlclean-loader](https://github.com/anseki/htmlclean-loader)\n\n**If you want to just clean files, [Command Line Tool](https://github.com/anseki/htmlclean-cli) is easy way.**\n\nSimple and safety HTML/SVG cleaner to minify without changing its structure.  \nSee [htmlclean](https://github.com/anseki/htmlclean) for options and more information about htmlclean.\n\n## Getting Started\n\nThis plugin requires Grunt `~0.4.1`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-htmlclean --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-htmlclean');\n```\n\n## Usage\n\nIn your project's Gruntfile, add a section named `htmlclean` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  htmlclean: {\n    options: {\n      protect: /\u003c\\!--%fooTemplate\\b.*?%--\u003e/g,\n      edit: function(html) { return html.replace(/\\begg(s?)\\b/ig, 'omelet$1'); }\n    },\n    deploy: {\n      expand: true,\n      cwd: 'develop/',\n      src: '**/*.html',\n      dest: 'public_html/'\n    }\n  }\n});\n```\n\nSee [htmlclean](https://github.com/anseki/htmlclean#options) for the options.\n\n## Working with grunt-task-helper\n\nFor example, you want to clean only changed HTML files. Then [grunt-task-helper](https://github.com/anseki/grunt-task-helper) helps it. In this case, using `handlerByContent` Function instead of this plugin is better. Because grunt parses `files` components in every tasks(targets). `handlerByContent` can be included to one task with other handlers (e.g. select changed HTML files).  \nSee [grunt-task-helper](https://github.com/anseki/grunt-task-helper).\n\nExample:\n\n`Gruntfile.js`\n\n```js\ngrunt.initConfig({\n  taskHelper: {\n    deploy: {\n      options: {\n        // Select files which are newer than `dest`.\n        handlerByFile: 'newFile',\n        // Clean the selected files.\n        handlerByContent: require('grunt-htmlclean/node_modules/htmlclean')\n        //handlerByContent: require('htmlclean') // If htmlclean is already installed. (Not grunt-htmlclean)\n      },\n      expand: true,\n      cwd: 'develop/',\n      src: '**/*.html',\n      dest: 'public_html/'\n    }\n  }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fgrunt-htmlclean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanseki%2Fgrunt-htmlclean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fgrunt-htmlclean/lists"}