diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb63387..8fdea18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,13 +7,13 @@ jobs: 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: diff --git a/package.json b/package.json index 971935c..cc6d07b 100644 --- a/package.json +++ b/package.json @@ -46,16 +46,16 @@ }, "devDependencies": { "@types/node": "^20.0.0", - "c8": "^8.0.0", + "c8": "^10.0.0", "html-void-elements": "^3.0.0", "micromark": "^4.0.0", "micromark-build": "^2.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", - "xo": "^0.56.0" + "xo": "^0.58.0" }, "scripts": { "prepack": "npm run build && npm run format", @@ -99,9 +99,10 @@ ], "prettier": true, "rules": { + "logical-assignment-operators": "off", "max-params": "off", - "unicorn/prefer-at": "off", - "unicorn/no-this-assignment": "off" + "unicorn/no-this-assignment": "off", + "unicorn/prefer-at": "off" } } } diff --git a/readme.md b/readme.md index 4bd1caa..7e69d9f 100644 --- a/readme.md +++ b/readme.md @@ -13,26 +13,26 @@ such). ## Contents -* [What is this?](#what-is-this) -* [When to use this](#when-to-use-this) -* [Install](#install) -* [Use](#use) -* [API](#api) - * [`directive()`](#directive) - * [`directiveHtml(options?)`](#directivehtmloptions) - * [`Directive`](#directive-1) - * [`Handle`](#handle) - * [`HtmlOptions`](#htmloptions) -* [Authoring](#authoring) -* [HTML](#html) -* [CSS](#css) -* [Syntax](#syntax) -* [Types](#types) -* [Compatibility](#compatibility) -* [Security](#security) -* [Related](#related) -* [Contribute](#contribute) -* [License](#license) +* [What is this?](#what-is-this) +* [When to use this](#when-to-use-this) +* [Install](#install) +* [Use](#use) +* [API](#api) + * [`directive()`](#directive) + * [`directiveHtml(options?)`](#directivehtmloptions) + * [`Directive`](#directive-1) + * [`Handle`](#handle) + * [`HtmlOptions`](#htmloptions) +* [Authoring](#authoring) +* [HTML](#html) +* [CSS](#css) +* [Syntax](#syntax) +* [Types](#types) +* [Compatibility](#compatibility) +* [Security](#security) +* [Related](#related) +* [Contribute](#contribute) +* [License](#license) ## What is this? @@ -155,8 +155,8 @@ HTML. ###### Parameters -* `options` ([`HtmlOptions`][api-html-options], default: `{}`) - — configuration +* `options` ([`HtmlOptions`][api-html-options], default: `{}`) + — configuration ###### Returns @@ -170,16 +170,16 @@ Structure representing a directive (TypeScript type). ###### Fields -* `type` (`'containerDirective'`, `'leafDirective'`, or `'textDirective'`) - — kind -* `name` (`string`) - — name of directive -* `label` (`string` or `undefined`) - — compiled HTML content that was in `[brackets]` -* `attributes` (`Record` or `undefined`) - — object w/ HTML attributes -* `content` (`string` or `undefined`) - — compiled HTML content inside container directive +* `type` (`'containerDirective'`, `'leafDirective'`, or `'textDirective'`) + — kind +* `name` (`string`) + — name of directive +* `label` (`string` or `undefined`) + — compiled HTML content that was in `[brackets]` +* `attributes` (`Record` or `undefined`) + — object w/ HTML attributes +* `content` (`string` or `undefined`) + — compiled HTML content inside container directive ### `Handle` @@ -187,10 +187,10 @@ Handle a directive (TypeScript type). ###### Parameters -* `this` ([`CompileContext`][micromark-compile-context]) - — current context -* `directive` ([`Directive`][api-directive-type]) - — directive +* `this` ([`CompileContext`][micromark-compile-context]) + — current context +* `directive` ([`Directive`][api-directive-type]) + — directive ###### Returns @@ -290,14 +290,14 @@ So this line is also part of the container. Note that while other implementations are sometimes loose in what they allow, this implementation mimics CommonMark as closely as possible: -* Whitespace is not allowed between colons and name (~~`: a`~~), name and - label (~~`:a []`~~), name and attributes (~~`:a {}`~~), or label and - attributes (~~`:a[] {}`~~) — because it’s not allowed in links either - (~~`[] ()`~~) -* No trailing colons allowed on the opening fence of a container - (~~`:::a:::`~~) — because it’s not allowed in fenced code either -* The label and attributes in a leaf or container cannot include line endings - (~~`::a[b\nc]`~~) — because it’s not allowed in fenced code either +* Whitespace is not allowed between colons and name (~~`: a`~~), name and + label (~~`:a []`~~), name and attributes (~~`:a {}`~~), or label and + attributes (~~`:a[] {}`~~) — because it’s not allowed in links either + (~~`[] ()`~~) +* No trailing colons allowed on the opening fence of a container + (~~`:::a:::`~~) — because it’s not allowed in fenced code either +* The label and attributes in a leaf or container cannot include line endings + (~~`::a[b\nc]`~~) — because it’s not allowed in fenced code either ## Types @@ -325,10 +325,10 @@ Any vulnerability in your code could open you to a ## Related -* [`remark-directive`][remark-directive] - — remark plugin to support directives -* [`mdast-util-directive`][mdast-util-directive] - — mdast utility to support directives +* [`remark-directive`][remark-directive] + — remark plugin to support directives +* [`mdast-util-directive`][mdast-util-directive] + — mdast utility to support directives ## Contribute diff --git a/test/index.js b/test/index.js index 03d91f1..fd6baf6 100644 --- a/test/index.js +++ b/test/index.js @@ -1678,10 +1678,10 @@ function abbr(d) { * @type {Handle} */ function youtube(d) { - const attrs = d.attributes || {} - const v = attrs.v + const attributes = d.attributes || {} + const v = attributes.v /** @type {string} */ - let prop + let key if (!v) return false @@ -1694,9 +1694,9 @@ function youtube(d) { list.push('title="' + this.encode(d.label) + '"') } - for (prop in attrs) { - if (prop !== 'v') { - list.push(this.encode(prop) + '="' + this.encode(attrs[prop]) + '"') + for (key in attributes) { + if (key !== 'v') { + list.push(this.encode(key) + '="' + this.encode(attributes[key]) + '"') } } @@ -1721,15 +1721,15 @@ function youtube(d) { */ function h(d) { const content = d.content || d.label - const attrs = d.attributes || {} + const attributes = d.attributes || {} /** @type {Array} */ const list = [] /** @type {string} */ - let prop + let key - for (prop in attrs) { - if (own.call(attrs, prop)) { - list.push(this.encode(prop) + '="' + this.encode(attrs[prop]) + '"') + for (key in attributes) { + if (own.call(attributes, key)) { + list.push(this.encode(key) + '="' + this.encode(attributes[key]) + '"') } }