{"id":16451571,"url":"https://github.com/pauldraper/html5-escape","last_synced_at":"2026-05-15T10:32:37.742Z","repository":{"id":67767154,"uuid":"147100442","full_name":"pauldraper/html5-escape","owner":"pauldraper","description":"Escape strings for HTML5 in a pleasing manner","archived":false,"fork":false,"pushed_at":"2018-09-02T16:41:27.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T15:14:26.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pauldraper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-09-02T16:01:12.000Z","updated_at":"2018-09-04T13:11:28.000Z","dependencies_parsed_at":"2023-02-24T10:00:51.753Z","dependency_job_id":null,"html_url":"https://github.com/pauldraper/html5-escape","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pauldraper/html5-escape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldraper%2Fhtml5-escape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldraper%2Fhtml5-escape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldraper%2Fhtml5-escape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldraper%2Fhtml5-escape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pauldraper","download_url":"https://codeload.github.com/pauldraper/html5-escape/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldraper%2Fhtml5-escape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33063242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-15T02:00:06.351Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-11T10:09:16.470Z","updated_at":"2026-05-15T10:32:37.711Z","avatar_url":"https://github.com/pauldraper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# html5-escape\n\nEscape strings for HTML5 in a pleasing manner.\n\nWhile it is relative unchallenging to sufficiently escape strings, this library escapes minimally.\nE.g.\n\n```javascript\nconst string = 'a \u0026\u0026 b';\n\n/* sufficiently */\nconst Serializer = require('parse5/lib/serializer');\nSerializer.escapeString(string);\n// 'a \u0026amp;\u0026amp; b'\n\n/* minimally */\nconst { Escaper } = require('html5-escape');\nnew Escaper().escapeData(string);\n// 'a \u0026\u0026 b'\n```\n\nhtml5-escape can optionally encode control or non-ASCII characters. It preferentially uses named entities when available (e.g. `'\u0026alpha;'`, `'\u0026nbsp;'`).\n\n## Usage\n\n```javascript\nimport { Escaper } from 'html5-escape';\n\nconst escaper = new Escaper();\nescaper.escapeData('\u003c Abbott \u0026 Costello \u0026me; \"on first\"');\n// '\u0026lt; Abbott \u0026 Costello \u0026amp;me;'\nescaper.escapeDoubleQuotedAttribute('\u003c Abbott \u0026 Costello \u0026me; \"on first\"');\n// '\u003c Abbott \u0026 Costello \u0026amp;me; \u0026quot;on first\u0026quote;'\n```\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Escaper\n\nEscape text for HTML5 documents.\n\nThe NUL character cannot be included in HTML documents. It is replaced with U+FFFD\n'REPLACEMENT CHARACTER'.\n\n#### Parameters\n\n- `options` **[Options](#options)** (optional, default `{}`)\n\n#### escapeData\n\n- **See: [HTML 5.2, 8.2.4.1](https://www.w3.org/TR/html52/syntax.html#data-state)**\n\nEscape a text node\n\n##### Parameters\n\n- `value` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** text to escape\n\n##### Examples\n\n```javascript\nescaper.escapeData('\u003c Abbott \u0026 Costello \u0026me; \"on first\"');\n// '\u0026lt; Abbott \u0026 Costello \u0026amp;me; \"on first\"'\n```\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** escaped text\n\n#### escapeDoubleQuotedAttribute\n\n- **See: [HTML 5.2, 8.2.4.36](https://www.w3.org/TR/html52/syntax.html#attribute-value-double-quoted-state)**\n\nEscape an attribute value using double-quotes\n\n##### Parameters\n\n- `value` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** text to escape\n\n##### Examples\n\n```javascript\nescaper.escapeData('\u003c Abbott \u0026 Costello \u0026me; \"on first\"');\n// '\u003c Abbott \u0026 Costello \u0026amp;me; \u0026quot;on first\u0026quot;'\n```\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** escaped text\n\n#### escapeSingleQuotedAttribute\n\n- **See: [HTML 5.2, 8.2.4.37](https://www.w3.org/TR/html52/syntax.html#attribute-value-single-quoted-state)**\n\nEscape an attribute value using single-quotes\n\n##### Parameters\n\n- `value` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** text to escape\n\n##### Examples\n\n```javascript\nescaper.escapeData('\u003c Abbott \u0026 Costello \u0026me; \"on first\"');\n// '\u003c Abbott \u0026 Costello \u0026amp;me; \"on first\"'\n```\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** escaped text\n\n#### escapeUnquotedAttribute\n\n- **See: [HTML 5.2, 8.2.4.38](https://www.w3.org/TR/html52/syntax.html#attribute-value-unquoted-state)**\n\nEscape an attribute value not using quotes\n\n##### Parameters\n\n- `value` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** text to escape\n\n##### Examples\n\n```javascript\nescaper.escapeData('\u003c Abbott \u0026 Costello \u0026me; \"on first\"');\n// '\u0026lt;\u0026#x20Abbott\u0026#x20\u0026\u0026#x20Costello\u0026#x20\u0026amp;me;\u0026#x20\u0026quot;on first\u0026quot;'\n```\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** escaped text\n\n### Options\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n#### Properties\n\n- `escapeRanges` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** zero or more of 'control', 'nonbreaking-space', and 'non-ascii'. Defaults to\n  ['control', 'nonbreaking-space']\n- `escapeBase` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** either 10 or 16. Defaults to 16.\n- `forceEscape` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** whether to coerce characters to alternative forms if necessary to escape them.\n  Defaults to true.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauldraper%2Fhtml5-escape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauldraper%2Fhtml5-escape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauldraper%2Fhtml5-escape/lists"}