{"id":16327072,"url":"https://github.com/mrmlnc/posthtml-attrs-sorter","last_synced_at":"2025-03-20T22:31:54.887Z","repository":{"id":57328788,"uuid":"50058102","full_name":"mrmlnc/posthtml-attrs-sorter","owner":"mrmlnc","description":":postbox: Sorting of the tag attributes in the specified order.","archived":false,"fork":false,"pushed_at":"2017-05-04T17:27:26.000Z","size":18,"stargazers_count":16,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T18:21:45.795Z","etag":null,"topics":["posthtml","posthtml-plugin"],"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/mrmlnc.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}},"created_at":"2016-01-20T20:28:45.000Z","updated_at":"2024-05-22T02:40:38.000Z","dependencies_parsed_at":"2022-09-07T16:30:24.527Z","dependency_job_id":null,"html_url":"https://github.com/mrmlnc/posthtml-attrs-sorter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fposthtml-attrs-sorter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fposthtml-attrs-sorter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fposthtml-attrs-sorter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fposthtml-attrs-sorter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrmlnc","download_url":"https://codeload.github.com/mrmlnc/posthtml-attrs-sorter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244703975,"owners_count":20496218,"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":["posthtml","posthtml-plugin"],"created_at":"2024-10-10T23:10:19.613Z","updated_at":"2025-03-20T22:31:54.647Z","avatar_url":"https://github.com/mrmlnc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# posthtml-attrs-sorter\n\n\u003e A [PostHTML](https://github.com/posthtml/posthtml) plugin for sort attribute of the tag based on the given order.\n\n[![Travis](https://img.shields.io/travis/mrmlnc/posthtml-attrs-sorter.svg?style=flat-square)](https://travis-ci.org/mrmlnc/posthtml-attrs-sorter)\n[![NPM version](https://img.shields.io/npm/v/posthtml-attrs-sorter.svg?style=flat-square)](https://www.npmjs.com/package/posthtml-attrs-sorter)\n[![devDependency Status](https://img.shields.io/david/mrmlnc/posthtml-attrs-sorter.svg?style=flat-square)](https://david-dm.org/mrmlnc/posthtml-attrs-sorter#info=dependencies)\n[![devDependency Status](https://img.shields.io/david/dev/mrmlnc/posthtml-attrs-sorter.svg?style=flat-square)](https://david-dm.org/mrmlnc/posthtml-attrs-sorter#info=devDependencies)\n\n## Install\n\n```shell\n$ npm i -D posthtml-attrs-sorter\n```\n\n## Why?\n\nTo follow the guidelines for writing code such as [Code Guide by @mdo](http://codeguide.co/).\n\n## Usage\n\n```js\nconst posthtml = require('posthtml');\nconst attrsSorter = require('posthtml-attrs-sorter');\nconst htmlRaw = fs.readFileSync('path/to/file.html');\n\nposthtml()\n  .use(attrsSorter({\n    // Options\n  }))\n  .process(htmlRaw)\n  .then(function(result) {\n     fs.writeFileSync('path/to/file.html');\n  })\n```\n\nYou can also use this plugin in the PostHTML plugin to [Gulp](https://www.npmjs.com/package/gulp-posthtml) or [Grunt](https://www.npmjs.com/package/grunt-posthtml).\n\n## Options\n\n#### order\n\n  * Type: `string[]`\n  * Info:\n    * Strings are turned into [Regular Expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)\n    * Use `$unknown$` to specify where the unsorted attributes are placed\n  * Default: http://codeguide.co/#html-attribute-order\n  \n```json\n{\n  \"order\": [\n    \"class\", \"id\", \"name\",\n    \"data-.+\", \"ng-.+\", \"src\",\n    \"for\", \"type\", \"href\",\n    \"values\", \"title\", \"alt\",\n    \"role\", \"aria-.+\",\n    \"$unknown$\"\n  ]\n}\n```\n\nAn array of attributes in the correct order.\n\n## Plugins for editors and IDE\n\n  * [Visual Studio Code](https://github.com/mrmlnc/vscode-attrs-sorter)\n\n## Changelog\n\nSee the [Releases section of our GitHub project](https://github.com/mrmlnc/posthtml-attrs-sorter/releases) for changelogs for each release version.\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmlnc%2Fposthtml-attrs-sorter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrmlnc%2Fposthtml-attrs-sorter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmlnc%2Fposthtml-attrs-sorter/lists"}