diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb63387..2ce794f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,21 +1,21 @@ -name: main -on: - - pull_request - - push jobs: main: name: ${{matrix.node}} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{matrix.node}} - run: npm install - run: npm test - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 strategy: matrix: node: - - lts/gallium + - lts/hydrogen - node +name: main +on: + - pull_request + - push diff --git a/.gitignore b/.gitignore index c977c85..40205b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +*.d.ts.map *.d.ts *.log coverage/ diff --git a/lib/handle/comment.js b/lib/handle/comment.js index 95ff4aa..3a49064 100644 --- a/lib/handle/comment.js +++ b/lib/handle/comment.js @@ -1,8 +1,6 @@ /** - * @typedef {import('hast').Comment} Comment - * @typedef {import('hast').Parents} Parents - * - * @typedef {import('../index.js').State} State + * @import {Comment, Parents} from 'hast' + * @import {State} from '../index.js' */ import {stringifyEntities} from 'stringify-entities' diff --git a/lib/handle/doctype.js b/lib/handle/doctype.js index d2b9c4a..36b43ad 100644 --- a/lib/handle/doctype.js +++ b/lib/handle/doctype.js @@ -1,13 +1,8 @@ /** - * @typedef {import('hast').Doctype} Doctype - * @typedef {import('hast').Parents} Parents - * - * @typedef {import('../index.js').State} State + * @import {Doctype, Parents} from 'hast' + * @import {State} from '../index.js' */ -// Make VS code see references to the above types. -'' - /** * Serialize a doctype. * diff --git a/lib/handle/element.js b/lib/handle/element.js index 217f105..17b4713 100644 --- a/lib/handle/element.js +++ b/lib/handle/element.js @@ -1,9 +1,6 @@ /** - * @typedef {import('hast').Element} Element - * @typedef {import('hast').Parents} Parents - * @typedef {import('hast').Properties} Properties - * - * @typedef {import('../index.js').State} State + * @import {Element, Parents, Properties} from 'hast' + * @import {State} from '../index.js' */ import {ccount} from 'ccount' diff --git a/lib/handle/index.js b/lib/handle/index.js index e861c01..31401e1 100644 --- a/lib/handle/index.js +++ b/lib/handle/index.js @@ -1,8 +1,6 @@ /** - * @typedef {import('hast').Nodes} Nodes - * @typedef {import('hast').Parents} Parents - * - * @typedef {import('../index.js').State} State + * @import {Nodes, Parents} from 'hast' + * @import {State} from '../index.js' */ import {zwitch} from 'zwitch' diff --git a/lib/handle/raw.js b/lib/handle/raw.js index 6c89a11..834ab92 100644 --- a/lib/handle/raw.js +++ b/lib/handle/raw.js @@ -1,9 +1,7 @@ /** - * @typedef {import('hast').Parents} Parents - * - * @typedef {import('mdast-util-to-hast').Raw} Raw - * - * @typedef {import('../index.js').State} State + * @import {Parents} from 'hast' + * @import {Raw} from 'mdast-util-to-hast' + * @import {State} from '../index.js' */ import {text} from './text.js' diff --git a/lib/handle/root.js b/lib/handle/root.js index ccd84e1..97ef35b 100644 --- a/lib/handle/root.js +++ b/lib/handle/root.js @@ -1,13 +1,8 @@ /** - * @typedef {import('hast').Parents} Parents - * @typedef {import('hast').Root} Root - * - * @typedef {import('../index.js').State} State + * @import {Parents, Root} from 'hast' + * @import {State} from '../index.js' */ -// Make VS code see references to the above types. -'' - /** * Serialize a root. * diff --git a/lib/handle/text.js b/lib/handle/text.js index af08b28..03cefde 100644 --- a/lib/handle/text.js +++ b/lib/handle/text.js @@ -1,10 +1,7 @@ /** - * @typedef {import('hast').Parents} Parents - * @typedef {import('hast').Text} Text - * - * @typedef {import('mdast-util-to-hast').Raw} Raw - * - * @typedef {import('../index.js').State} State + * @import {Parents, Text} from 'hast' + * @import {Raw} from 'mdast-util-to-hast' + * @import {State} from '../index.js' */ import {stringifyEntities} from 'stringify-entities' diff --git a/lib/index.js b/lib/index.js index 93bb730..05da5b5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,7 @@ /** - * @typedef {import('hast').Nodes} Nodes - * @typedef {import('hast').Parents} Parents - * @typedef {import('hast').RootContent} RootContent - * - * @typedef {import('property-information').Schema} Schema - * - * @typedef {import('stringify-entities').Options} StringifyEntitiesOptions + * @import {Nodes, Parents, RootContent} from 'hast' + * @import {Schema} from 'property-information' + * @import {Options as StringifyEntitiesOptions} from 'stringify-entities' */ /** @@ -77,10 +73,10 @@ * Leave attributes unquoted if that results in less bytes (default: `false`). * * Not used in the SVG space. - * @property {Quote | null | undefined} [quote='"'] - * Preferred quote to use (default: `'"'`). * @property {boolean | null | undefined} [quoteSmart=false] * Use the other quote if that results in less bytes (default: `false`). + * @property {Quote | null | undefined} [quote='"'] + * Preferred quote to use (default: `'"'`). * @property {Space | null | undefined} [space='html'] * When an `<svg>` element is found in the HTML space, this package already * automatically switches to and from the SVG space when entering and exiting @@ -138,18 +134,18 @@ * * @typedef State * Info passed around about the current state. - * @property {(node: Nodes, index: number | undefined, parent: Parents | undefined) => string} one - * Serialize one node. * @property {(node: Parents | undefined) => string} all * Serialize the children of a parent node. - * @property {Settings} settings - * User configuration. - * @property {Schema} schema - * Current schema. - * @property {Quote} quote - * Preferred quote. * @property {Quote} alternative * Alternative quote. + * @property {(node: Nodes, index: number | undefined, parent: Parents | undefined) => string} one + * Serialize one node. + * @property {Quote} quote + * Preferred quote. + * @property {Schema} schema + * Current schema. + * @property {Settings} settings + * User configuration. */ import {htmlVoidElements} from 'html-void-elements' diff --git a/lib/omission/closing.js b/lib/omission/closing.js index a7cd1a1..b30baf7 100644 --- a/lib/omission/closing.js +++ b/lib/omission/closing.js @@ -1,6 +1,5 @@ /** - * @typedef {import('hast').Element} Element - * @typedef {import('hast').Parents} Parents + * @import {Element, Parents} from 'hast' */ import {whitespace} from 'hast-util-whitespace' diff --git a/lib/omission/omission.js b/lib/omission/omission.js index 692101c..902f38f 100644 --- a/lib/omission/omission.js +++ b/lib/omission/omission.js @@ -1,6 +1,5 @@ /** - * @typedef {import('hast').Element} Element - * @typedef {import('hast').Parents} Parents + * @import {Element, Parents} from 'hast' */ /** diff --git a/lib/omission/opening.js b/lib/omission/opening.js index 65c9964..edc878c 100644 --- a/lib/omission/opening.js +++ b/lib/omission/opening.js @@ -1,6 +1,5 @@ /** - * @typedef {import('hast').Element} Element - * @typedef {import('hast').Parents} Parents + * @import {Element, Parents} from 'hast' */ import {whitespace} from 'hast-util-whitespace' diff --git a/lib/omission/util/siblings.js b/lib/omission/util/siblings.js index c686a17..09edae4 100644 --- a/lib/omission/util/siblings.js +++ b/lib/omission/util/siblings.js @@ -1,6 +1,5 @@ /** - * @typedef {import('hast').Parents} Parents - * @typedef {import('hast').RootContent} RootContent + * @import {Parents, RootContent} from 'hast' */ import {whitespace} from 'hast-util-whitespace' diff --git a/package.json b/package.json index 3638e73..cdbb819 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hast-util-to-html", - "version": "9.0.1", + "version": "9.0.2", "description": "hast utility to serialize to HTML", "license": "MIT", "keywords": [ @@ -29,6 +29,7 @@ "exports": "./index.js", "files": [ "lib/", + "index.d.ts.map", "index.d.ts", "index.js" ], @@ -37,7 +38,6 @@ "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", - "hast-util-raw": "^9.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", @@ -47,16 +47,16 @@ "zwitch": "^2.0.4" }, "devDependencies": { - "@types/node": "^20.0.0", - "c8": "^9.0.0", + "@types/node": "^22.0.0", + "c8": "^10.0.0", "hastscript": "^9.0.0", "prettier": "^3.0.0", - "remark-cli": "^11.0.0", - "remark-preset-wooorm": "^9.0.0", + "remark-cli": "^12.0.0", + "remark-preset-wooorm": "^10.0.0", "type-coverage": "^2.0.0", "typescript": "^5.0.0", "unist-builder": "^4.0.0", - "xo": "^0.58.0" + "xo": "^0.59.0" }, "scripts": { "prepack": "npm run build && npm run format", diff --git a/readme.md b/readme.md index 8790ee5..d3d8820 100644 --- a/readme.md +++ b/readme.md @@ -12,23 +12,23 @@ ## Contents -* [What is this?](#what-is-this) -* [When should I use this?](#when-should-i-use-this) -* [Install](#install) -* [Use](#use) -* [API](#api) - * [`toHtml(tree[, options])`](#tohtmltree-options) - * [`CharacterReferences`](#characterreferences) - * [`Options`](#options) - * [`Quote`](#quote-1) - * [`Space`](#space-1) -* [Syntax](#syntax) -* [Types](#types) -* [Compatibility](#compatibility) -* [Security](#security) -* [Related](#related) -* [Contribute](#contribute) -* [License](#license) +* [What is this?](#what-is-this) +* [When should I use this?](#when-should-i-use-this) +* [Install](#install) +* [Use](#use) +* [API](#api) + * [`toHtml(tree[, options])`](#tohtmltree-options) + * [`CharacterReferences`](#characterreferences) + * [`Options`](#options) + * [`Quote`](#quote-1) + * [`Space`](#space-1) +* [Syntax](#syntax) +* [Types](#types) +* [Compatibility](#compatibility) +* [Security](#security) +* [Related](#related) +* [Contribute](#contribute) +* [License](#license) ## What is this? @@ -89,7 +89,7 @@ npm install hastscript hast-util-to-html import {h} from 'hastscript' import {toHtml} from 'hast-util-to-html' -var tree = h('.alpha', [ +const tree = h('.alpha', [ 'bravo ', h('b', 'charlie'), ' delta ', @@ -116,10 +116,10 @@ Serialize hast as HTML. ###### Parameters -* `tree` ([`Node`][node] or `Array<Node>`) - — tree to serialize -* `options` ([`Options`][api-options], optional) - — configuration +* `tree` ([`Node`][node] or `Array<Node>`) + — tree to serialize +* `options` ([`Options`][api-options], optional) + — configuration ###### Returns @@ -365,8 +365,8 @@ Use [`hast-util-santize`][hast-util-sanitize] to make the hast tree safe. ## Related -* [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize) - — sanitize hast +* [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize) + — sanitize hast ## Contribute diff --git a/test/raw.js b/test/raw.js index 3ad8b94..6b586f5 100644 --- a/test/raw.js +++ b/test/raw.js @@ -1,5 +1,5 @@ /** - * @typedef {import('hast-util-raw')} DoNotTouchThisRegistersRawInTheTree + * @import {} from 'mdast-util-to-hast' */ import assert from 'node:assert/strict' diff --git a/tsconfig.json b/tsconfig.json index 82cc749..4d9161a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "checkJs": true, "customConditions": ["development"], "declaration": true, + "declarationMap": true, "emitDeclarationOnly": true, "exactOptionalPropertyTypes": true, "lib": ["es2022"],