JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2360
  • Score
    100M100P100Q111241F
  • License MIT

Information for HTML doctypes

Package Exports

  • doctype

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (doctype) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

doctype

Build Coverage Downloads Size

Info on HTML / XHTML / MathML / SVG doctypes.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install doctype

Use

import {doctype} from 'doctype'

console.log(doctype(5)) // => 'html'

console.log(doctype(4.01))
console.log(doctype('4.01t'))
console.log(doctype('4.01 Transitional'))
console.log(doctype('HTML 4.01 Transitional'))
// => 'HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"'

console.log(doctype('svg'))
// => 'svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"'

API

This package exports the following identifiers: doctype and doctypes. There is no default export.

doctype(name)

Get a doctype, where name is stripped from white space, casing, fractional-part of version, 'HTML' or 'XHTML' prefix, and suffixes are normalised (Transitional to t).

Returns: string? — When applicable.

doctypes

{
  'HTML 5': 'html',
  'HTML 4.01 Strict': 'HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"',
  // ...
}

Object mapping doctype names to doctype strings. This gives raw access to the information returned by doctype().

License

MIT © Titus Wormer