{"id":15429524,"url":"https://github.com/wooorm/doctype","last_synced_at":"2025-04-19T16:53:26.062Z","repository":{"id":57214309,"uuid":"43945096","full_name":"wooorm/doctype","owner":"wooorm","description":"Info on HTML / XHTML / MathML / SVG doctypes","archived":false,"fork":false,"pushed_at":"2022-11-16T08:45:49.000Z","size":71,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T10:33:32.339Z","etag":null,"topics":["doctype","html","mathml","svg"],"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/wooorm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":"funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"wooorm"}},"created_at":"2015-10-09T09:13:16.000Z","updated_at":"2023-09-08T17:02:26.000Z","dependencies_parsed_at":"2022-08-26T13:41:31.048Z","dependency_job_id":null,"html_url":"https://github.com/wooorm/doctype","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fdoctype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fdoctype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fdoctype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fdoctype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wooorm","download_url":"https://codeload.github.com/wooorm/doctype/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249194590,"owners_count":21228032,"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":["doctype","html","mathml","svg"],"created_at":"2024-10-01T18:11:23.211Z","updated_at":"2025-04-19T16:53:26.026Z","avatar_url":"https://github.com/wooorm.png","language":"JavaScript","readme":"# doctype\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\nInfo on HTML, XHTML, MathML, and SVG doctypes.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`doctype(name)`](#doctypename)\n    *   [`doctypes`](#doctypes)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package lists known doctypes and exposes a function to turn a fuzzy name\n(such as `html`, `5`) into a corresponding doctype.\n\n## When should I use this?\n\nThis package is rather niche, using something other than `\u003c!doctype html\u003e` is\nalmost never needed anymore.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 14.14+, 16.0+), install with [npm][]:\n\n```sh\nnpm install doctype\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {doctype} from 'https://esm.sh/doctype@3'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {doctype} from 'https://esm.sh/doctype@3?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {doctype} from 'doctype'\n\nconsole.log(doctype(5)) // =\u003e 'html'\n\nconsole.log(doctype(4.01))\nconsole.log(doctype('4.01t'))\nconsole.log(doctype('4.01 Transitional'))\nconsole.log(doctype('HTML 4.01 Transitional'))\n// =\u003e 'HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"'\n\nconsole.log(doctype('svg'))\n// =\u003e 'svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"'\n```\n\n## API\n\nThis package exports the identifiers `doctype` and `doctypes`.\nThere is no default export.\n\n### `doctype(name)`\n\nGet a doctype from a fuzzy doctype name.\n\n###### Parameters\n\n*   `name` (`string`, `number`)\n    — fuzzy doctype name which is stripped from white space, casing, fractional\n    part of version, `'HTML'` or `'XHTML'` prefix, and whose suffixes are\n    normalized (`Transitional` to `t`)\n\n###### Returns\n\nDoctype string when found (`string|null`).\n\n### `doctypes`\n\nMap of doctype names to doctype values (`Record\u003cstring, string\u003e`).\n\n```js\n{\n  'HTML 5': 'html',\n  'HTML 4.01 Strict': 'HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"',\n  // …\n}\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nThis package is at least compatible with all maintained versions of Node.js.\nAs of now, that is Node.js 14.14+ and 16.0+.\nIt also works in Deno and modern browsers.\n\n## Security\n\nThis package is safe.\n\n## Related\n\n*   [`wooorm/html-tag-names`](https://github.com/wooorm/html-tag-names)\n    — list of HTML tag names\n*   [`wooorm/html-element-attributes`](https://github.com/wooorm/html-element-attributes)\n    — map of HTML attributes\n*   [`wooorm/html-void-elements`](https://github.com/wooorm/html-void-elements)\n    — list of void HTML tag-names\n*   [`wooorm/property-information`](https://github.com/wooorm/property-information)\n    — info on HTML, SVG, etc properties\n*   [`wooorm/web-namespaces`](https://github.com/wooorm/web-namespaces)\n    — map of web namespaces\n\n## Contribute\n\nYes please!\nSee [How to Contribute to Open Source][contribute].\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/wooorm/doctype/workflows/main/badge.svg\n\n[build]: https://github.com/wooorm/doctype/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/doctype.svg\n\n[coverage]: https://codecov.io/github/wooorm/doctype\n\n[downloads-badge]: https://img.shields.io/npm/dm/doctype.svg\n\n[downloads]: https://www.npmjs.com/package/doctype\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/doctype.svg\n\n[size]: https://bundlephobia.com/result?p=doctype\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esmsh]: https://esm.sh\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[typescript]: https://www.typescriptlang.org\n\n[contribute]: https://opensource.guide/how-to-contribute/\n","funding_links":["https://github.com/sponsors/wooorm"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fdoctype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooorm%2Fdoctype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fdoctype/lists"}