{"id":23250676,"url":"https://github.com/email-types/doctype","last_synced_at":"2025-04-06T02:15:01.137Z","repository":{"id":57222824,"uuid":"228430954","full_name":"email-types/doctype","owner":"email-types","description":"Easily manage your email's Document Type Definition (DTD).","archived":false,"fork":false,"pushed_at":"2019-12-23T14:20:40.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"canary","last_synced_at":"2025-03-12T10:02:48.467Z","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/email-types.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-16T16:41:48.000Z","updated_at":"2019-12-23T14:09:20.000Z","dependencies_parsed_at":"2022-09-08T23:01:35.887Z","dependency_job_id":null,"html_url":"https://github.com/email-types/doctype","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/email-types%2Fdoctype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/email-types%2Fdoctype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/email-types%2Fdoctype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/email-types%2Fdoctype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/email-types","download_url":"https://codeload.github.com/email-types/doctype/tar.gz/refs/heads/canary","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423522,"owners_count":20936626,"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":[],"created_at":"2024-12-19T09:14:29.147Z","updated_at":"2025-04-06T02:15:01.107Z","avatar_url":"https://github.com/email-types.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[wiki-dtd]: https://en.wikipedia.org/wiki/Document_type_definition\n[dtd-data]: ./src/data.ts\n\n\u003cdiv align=\"center\"\u003e\n\n# Email Doctype\n\nEasily manage your email's [Document Type Definition (DTD)][wiki-dtd].\n\n[![](https://img.shields.io/npm/v/email-doctype?color=black\u0026logoColor=white)](https://www.npmjs.com/package/email-doctype)\n![](https://img.shields.io/github/workflow/status/email-types/doctype/Test?logo=github\u0026color=black)\n[![](https://img.shields.io/codecov/c/github/email-types/doctype?logo=codecov\u0026logoColor=white\u0026color=black)](https://codecov.io/gh/email-types/doctype)\n[![](https://img.shields.io/bundlephobia/min/email-doctype?logo=bundlephobia\u0026color=black)](https://bundlephobia.com/result?p=email-doctype)\n[![](https://img.shields.io/bundlephobia/minzip/email-doctype?logo=bundlephobia\u0026color=black)](https://bundlephobia.com/result?p=email-doctype)\n\n\u003c/div\u003e\n\nInstall with yarn\n\n```sh\nyarn add email-doctype\n```\n\nOr install with npm:\n\n```sh\nnpm install email-doctype\n```\n\n## Doctypes\n\n| Keys                     | Alias Prefix   | Alias Version | Alias Suffix          |\n| :----------------------- | :------------- | :------------ | :-------------------- |\n| `html-5`                 | `h` or `html`  | `5`           | n/a                   |\n| `html-4.01-strict`       | `h` or `html`  | `4.01`        | `s` or `strict`       |\n| `html-4.01-transitional` | `h` or `html`  | n/a           | `t` or `transitional` |\n| `xhtml-1.1`              | `x` or `xhtml` | `1.1`         | n/a                   |\n| `xhtml-1.0-strict`       | `x` or `xhtml` | `1` or `1.0`  | `s` or `strict`       |\n| `xhtml-1.0-transitional` | `x` or `xhtml` | n/a           | `t` or `transitional` |\n\n**Aliases**\n\nWhile you can easily get a doctype using a `Key`, you can also use an alias. An\nalias can be an `Alias Version` or string composing of an `Alias Prefix`,\n`Alias Version`, and `Alias Suffix`.\n\n- Casing will be normalized so `keys` and `aliases` are case insensitive\n- Whitespace is removed so spaces are allowed\n- When there is an `Alias Suffix` available but not used, the returned doctype\n  will use the `strict` alias suffix\n\n**Examples**\n\nCheckout the [test](./test/index.test.ts) for more examples.\n\n```ts\nimport * as doctype from 'email-doctype';\n\ndoctype.version('recommended');\ndoctype.version('html-1.0-transitional');\ndoctype.version('XHTML 1.0 Transitional');\n// =\u003e '\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"\u003e'\n\ndoctype.version(5);\ndoctype.version('html-5');\ndoctype.version('HTML 5');\n// =\u003e '\u003c!DOCTYPE html\u003e'\n\ndoctype.version(4.01);\ndoctype.version('xhtml-4.01-strict');\n// =\u003e '\u003c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"\u003e'\n\ndoctype.version(1.1);\ndoctype.version('xhtml-1.1');\ndoctype.version('XHTML 1.1');\n// =\u003e '\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"\u003e'\n\ndoctype.version(1.0);\ndoctype.version('xhtml-1.0-strict');\ndoctype.version('XHTML 1.0 Strict');\n// =\u003e '\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\u003e'\n```\n\n## Extracting a doctype\n\nExtract the doctype from a given html string.\n\n```ts\nimport { extract } from 'email-doctype';\n\nconst html = '\u003c!DOCTYPE html\u003e \u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e';\n\nextract(html);\n// =\u003e '\u003c!DOCTYPE html\u003e'\n```\n\n## Setting a doctype\n\nAdd a doctype to a given html string.\n\n```ts\nimport { set } from 'email-doctype';\n\nconst html = '\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e';\n\nset(html, 'HTML 5');\n// =\u003e '\u003c!DOCTYPE html\u003e \u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e'\n```\n\n**Automatic replacement**\n\nWhen the given html contains a doctype, it will be automatically replaced with\nyour new doctype.\n\n```ts\nimport { set } from 'email-doctype';\n\nconst html = '\u003c!DOCTYPE html\u003e \u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e';\n\nset(html, 'HTML 4.01');\n// '\u003c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"\u003e \u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e'\n```\n\n## Removing a doctype\n\nRemove a given html string's doctype, returning just the html.\n\n```ts\nimport { remove } from 'email-doctype';\n\nconst html = '\u003c!DOCTYPE html\u003e \u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e';\n\nremove(html);\n// =\u003e '\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e'\n```\n\n## API\n\n### version\n\n```ts\nversion(alias: string): string\n```\n\nGets a doctype from a given alias.\n\n### extract\n\n```ts\nextract(html: string): string\n```\n\nExtracts the doctype from a given html string.\n\n### set\n\n```ts\nset(html: string, alias: string = 'recommended'): string\n```\n\nAdds a doctype to a given html string.\n\n### remove\n\n```ts\nremove(html: string): string\n```\n\nRemoves a given html string's doctype, returning just the html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femail-types%2Fdoctype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femail-types%2Fdoctype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femail-types%2Fdoctype/lists"}