Compare commits
No commits in common. "main" and "3.0.0" have entirely different histories.
13 changed files with 193 additions and 257 deletions
|
@ -1,9 +1,9 @@
|
||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
charset = utf-8
|
|
||||||
end_of_line = lf
|
|
||||||
indent_size = 2
|
|
||||||
indent_style = space
|
indent_style = space
|
||||||
insert_final_newline = true
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
12
.github/workflows/bb.yml
vendored
12
.github/workflows/bb.yml
vendored
|
@ -1,3 +1,9 @@
|
||||||
|
name: bb
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened, reopened, edited, closed, labeled, unlabeled]
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, reopened, edited, closed, labeled, unlabeled]
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -5,9 +11,3 @@ jobs:
|
||||||
- uses: unifiedjs/beep-boop-beta@main
|
- uses: unifiedjs/beep-boop-beta@main
|
||||||
with:
|
with:
|
||||||
repo-token: ${{secrets.GITHUB_TOKEN}}
|
repo-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
name: bb
|
|
||||||
on:
|
|
||||||
issues:
|
|
||||||
types: [closed, edited, labeled, opened, reopened, unlabeled]
|
|
||||||
pull_request_target:
|
|
||||||
types: [closed, edited, labeled, opened, reopened, unlabeled]
|
|
||||||
|
|
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
|
@ -1,21 +1,21 @@
|
||||||
|
name: main
|
||||||
|
on:
|
||||||
|
- pull_request
|
||||||
|
- push
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
name: ${{matrix.node}}
|
name: ${{matrix.node}}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{matrix.node}}
|
node-version: ${{matrix.node}}
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm test
|
- run: npm test
|
||||||
- uses: codecov/codecov-action@v5
|
- uses: codecov/codecov-action@v3
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node:
|
node:
|
||||||
- lts/hydrogen
|
- lts/gallium
|
||||||
- node
|
- node
|
||||||
name: main
|
|
||||||
on:
|
|
||||||
- pull_request
|
|
||||||
- push
|
|
||||||
|
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,9 +1,6 @@
|
||||||
*.d.ts
|
|
||||||
*.log
|
|
||||||
*.map
|
|
||||||
*.tsbuildinfo
|
|
||||||
.DS_Store
|
|
||||||
coverage/
|
coverage/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.DS_Store
|
||||||
|
*.d.ts
|
||||||
|
*.log
|
||||||
yarn.lock
|
yarn.lock
|
||||||
!/index.d.ts
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
*.md
|
|
||||||
coverage/
|
coverage/
|
||||||
|
*.json
|
||||||
|
*.md
|
||||||
|
|
15
index.d.ts
vendored
15
index.d.ts
vendored
|
@ -1,15 +0,0 @@
|
||||||
import type {ToMarkdownOptions} from 'mdast-util-directive'
|
|
||||||
|
|
||||||
export {default} from './lib/index.js'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for `remark-directive`.
|
|
||||||
*
|
|
||||||
* Currently supports
|
|
||||||
* `collapseEmptyAttributes`,
|
|
||||||
* `preferShortcut`,
|
|
||||||
* `preferUnquoted`,
|
|
||||||
* `quoteSmart`,
|
|
||||||
* and `quote` as serialization options.
|
|
||||||
*/
|
|
||||||
export interface Options extends ToMarkdownOptions {}
|
|
1
index.js
1
index.js
|
@ -1,2 +1 @@
|
||||||
// Note: types exposed from `index.d.ts`.
|
|
||||||
export {default} from './lib/index.js'
|
export {default} from './lib/index.js'
|
||||||
|
|
41
lib/index.js
41
lib/index.js
|
@ -1,16 +1,14 @@
|
||||||
|
/// <reference types="remark-parse" />
|
||||||
|
/// <reference types="remark-stringify" />
|
||||||
|
/// <reference types="mdast-util-directive" />
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @import {} from 'mdast-util-directive'
|
* @typedef {import('mdast').Root} Root
|
||||||
* @import {Root} from 'mdast'
|
* @typedef {import('unified').Processor<Root>} Processor
|
||||||
* @import {} from 'remark-arse'
|
|
||||||
* @import {} from 'remark-stringify'
|
|
||||||
* @import {Processor} from 'unified'
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {directiveFromMarkdown, directiveToMarkdown} from 'mdast-util-directive'
|
||||||
directiveFromMarkdown,
|
import {directive} from 'micromark-extension-directive'
|
||||||
directiveToMarkdown,
|
|
||||||
} from "mdast-util-directive";
|
|
||||||
import { directive } from "micromark-extension-directive";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add support for generic directives.
|
* Add support for generic directives.
|
||||||
|
@ -23,16 +21,19 @@ import { directive } from "micromark-extension-directive";
|
||||||
* Nothing.
|
* Nothing.
|
||||||
*/
|
*/
|
||||||
export default function remarkDirective() {
|
export default function remarkDirective() {
|
||||||
const data = this.data();
|
// @ts-expect-error: TS is wrong about `this`.
|
||||||
|
// eslint-disable-next-line unicorn/no-this-assignment
|
||||||
|
const self = /** @type {Processor} */ (this)
|
||||||
|
const data = self.data()
|
||||||
|
|
||||||
const micromarkExtensions =
|
const micromarkExtensions =
|
||||||
data.micromarkExtensions || (data.micromarkExtensions = []);
|
data.micromarkExtensions || (data.micromarkExtensions = [])
|
||||||
const fromMarkdownExtensions =
|
const fromMarkdownExtensions =
|
||||||
data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])
|
||||||
const toMarkdownExtensions =
|
const toMarkdownExtensions =
|
||||||
data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
data.toMarkdownExtensions || (data.toMarkdownExtensions = [])
|
||||||
|
|
||||||
micromarkExtensions.push(directive());
|
micromarkExtensions.push(directive())
|
||||||
fromMarkdownExtensions.push(directiveFromMarkdown());
|
fromMarkdownExtensions.push(directiveFromMarkdown())
|
||||||
toMarkdownExtensions.push(directiveToMarkdown());
|
toMarkdownExtensions.push(directiveToMarkdown())
|
||||||
}
|
}
|
||||||
|
|
2
license
2
license
|
@ -1,6 +1,6 @@
|
||||||
(The MIT License)
|
(The MIT License)
|
||||||
|
|
||||||
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|
196
package.json
196
package.json
|
@ -1,106 +1,94 @@
|
||||||
{
|
{
|
||||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
"name": "remark-directive",
|
||||||
"bugs": "https://github.com/remarkjs/remark-directive/issues",
|
"version": "3.0.0",
|
||||||
"contributors": ["Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"],
|
"description": "remark plugin to support directives",
|
||||||
"dependencies": {
|
"license": "MIT",
|
||||||
"@types/mdast": "^4.0.0",
|
"keywords": [
|
||||||
"mdast-util-directive": "^3.0.0",
|
"container",
|
||||||
"micromark-extension-directive": "git+https://git.v-sli.me/HidemaruOwO/micromark-extension-directive.git#fix.1",
|
"directive",
|
||||||
"unified": "^11.0.0"
|
"generic",
|
||||||
},
|
"markdown",
|
||||||
"description": "remark plugin to support directives",
|
"mdast",
|
||||||
"devDependencies": {
|
"plugin",
|
||||||
"@types/node": "^22.0.0",
|
"remark",
|
||||||
"c8": "^10.0.0",
|
"remark-plugin",
|
||||||
"is-hidden": "^2.0.0",
|
"unified"
|
||||||
"prettier": "^3.0.0",
|
],
|
||||||
"remark": "^15.0.0",
|
"repository": "remarkjs/remark-directive",
|
||||||
"remark-cli": "^12.0.0",
|
"bugs": "https://github.com/remarkjs/remark-directive/issues",
|
||||||
"remark-preset-wooorm": "^10.0.0",
|
"funding": {
|
||||||
"to-vfile": "^8.0.0",
|
"type": "opencollective",
|
||||||
"type-coverage": "^2.0.0",
|
"url": "https://opencollective.com/unified"
|
||||||
"typescript": "^5.0.0",
|
},
|
||||||
"xo": "^0.60.0"
|
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||||
},
|
"contributors": [
|
||||||
"exports": "./index.js",
|
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||||
"files": ["index.d.ts", "index.js", "lib/"],
|
],
|
||||||
"funding": {
|
"sideEffects": false,
|
||||||
"type": "opencollective",
|
"type": "module",
|
||||||
"url": "https://opencollective.com/unified"
|
"exports": "./index.js",
|
||||||
},
|
"files": [
|
||||||
"keywords": [
|
"lib/",
|
||||||
"container",
|
"index.d.ts",
|
||||||
"directive",
|
"index.js"
|
||||||
"generic",
|
],
|
||||||
"markdown",
|
"dependencies": {
|
||||||
"mdast",
|
"@types/mdast": "^4.0.0",
|
||||||
"plugin",
|
"mdast-util-directive": "^3.0.0",
|
||||||
"remark-plugin",
|
"micromark-extension-directive": "^3.0.0",
|
||||||
"remark",
|
"unified": "^11.0.0"
|
||||||
"unified"
|
},
|
||||||
],
|
"devDependencies": {
|
||||||
"license": "MIT",
|
"@types/node": "^20.0.0",
|
||||||
"name": "remark-directive",
|
"c8": "^8.0.0",
|
||||||
"prettier": {
|
"is-hidden": "^2.0.0",
|
||||||
"bracketSpacing": false,
|
"prettier": "^3.0.0",
|
||||||
"singleQuote": true,
|
"remark": "^15.0.0",
|
||||||
"semi": false,
|
"remark-cli": "^11.0.0",
|
||||||
"tabWidth": 2,
|
"remark-preset-wooorm": "^9.0.0",
|
||||||
"trailingComma": "none",
|
"to-vfile": "^8.0.0",
|
||||||
"useTabs": false
|
"type-coverage": "^2.0.0",
|
||||||
},
|
"typescript": "^5.0.0",
|
||||||
"remarkConfig": {
|
"xo": "^0.56.0"
|
||||||
"plugins": ["remark-preset-wooorm"]
|
},
|
||||||
},
|
"scripts": {
|
||||||
"repository": "remarkjs/remark-directive",
|
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||||
"scripts": {
|
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix",
|
||||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
"prepack": "npm run build && npm run format",
|
||||||
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix",
|
"test": "npm run build && npm run format && npm run test-coverage",
|
||||||
"prepack": "npm run build && npm run format",
|
"test-api": "node --conditions development test/index.js",
|
||||||
"test-api": "node --conditions development test/index.js",
|
"test-coverage": "c8 --100 --reporter lcov npm run test-api"
|
||||||
"test-coverage": "c8 --100 --reporter lcov -- npm run test-api",
|
},
|
||||||
"test": "npm run build && npm run format && npm run test-coverage"
|
"prettier": {
|
||||||
},
|
"bracketSpacing": false,
|
||||||
"sideEffects": false,
|
"singleQuote": true,
|
||||||
"typeCoverage": {
|
"semi": false,
|
||||||
"atLeast": 100,
|
"tabWidth": 2,
|
||||||
"strict": true
|
"trailingComma": "none",
|
||||||
},
|
"useTabs": false
|
||||||
"type": "module",
|
},
|
||||||
"version": "3.0.1",
|
"remarkConfig": {
|
||||||
"xo": {
|
"plugins": [
|
||||||
"overrides": [
|
"remark-preset-wooorm"
|
||||||
{
|
]
|
||||||
"files": ["**/*.d.ts"],
|
},
|
||||||
"rules": {
|
"typeCoverage": {
|
||||||
"@typescript-eslint/array-type": [
|
"atLeast": 100,
|
||||||
"error",
|
"detail": true,
|
||||||
{
|
"ignoreCatch": true,
|
||||||
"default": "generic"
|
"strict": true
|
||||||
}
|
},
|
||||||
],
|
"xo": {
|
||||||
"@typescript-eslint/ban-types": [
|
"overrides": [
|
||||||
"error",
|
{
|
||||||
{
|
"files": [
|
||||||
"extendDefaults": true
|
"test/**/*.js"
|
||||||
}
|
],
|
||||||
],
|
"rules": {
|
||||||
"@typescript-eslint/consistent-type-definitions": [
|
"no-await-in-loop": "off"
|
||||||
"error",
|
}
|
||||||
"interface"
|
}
|
||||||
]
|
],
|
||||||
}
|
"prettier": true
|
||||||
},
|
}
|
||||||
{
|
|
||||||
"files": ["test/**/*.js"],
|
|
||||||
"rules": {
|
|
||||||
"no-await-in-loop": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"prettier": true,
|
|
||||||
"rules": {
|
|
||||||
"logical-assignment-operators": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
138
readme.md
138
readme.md
|
@ -14,27 +14,26 @@ proposal][commonmark-prop] (`:cite[smith04]`,
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
* [What is this?](#what-is-this)
|
* [What is this?](#what-is-this)
|
||||||
* [When should I use this?](#when-should-i-use-this)
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
* [Install](#install)
|
* [Install](#install)
|
||||||
* [Use](#use)
|
* [Use](#use)
|
||||||
* [API](#api)
|
* [API](#api)
|
||||||
* [`unified().use(remarkDirective[, options])`](#unifieduseremarkdirective-options)
|
* [`unified().use(remarkDirective)`](#unifieduseremarkdirective)
|
||||||
* [`Options`](#options)
|
* [Examples](#examples)
|
||||||
* [Examples](#examples)
|
* [Example: YouTube](#example-youtube)
|
||||||
* [Example: YouTube](#example-youtube)
|
* [Example: Styled blocks](#example-styled-blocks)
|
||||||
* [Example: Styled blocks](#example-styled-blocks)
|
* [Authoring](#authoring)
|
||||||
* [Authoring](#authoring)
|
* [HTML](#html)
|
||||||
* [HTML](#html)
|
* [CSS](#css)
|
||||||
* [CSS](#css)
|
* [Syntax](#syntax)
|
||||||
* [Syntax](#syntax)
|
* [Syntax tree](#syntax-tree)
|
||||||
* [Syntax tree](#syntax-tree)
|
* [Types](#types)
|
||||||
* [Types](#types)
|
* [Compatibility](#compatibility)
|
||||||
* [Compatibility](#compatibility)
|
* [Security](#security)
|
||||||
* [Security](#security)
|
* [Related](#related)
|
||||||
* [Related](#related)
|
* [Contribute](#contribute)
|
||||||
* [Contribute](#contribute)
|
* [License](#license)
|
||||||
* [License](#license)
|
|
||||||
|
|
||||||
## What is this?
|
## What is this?
|
||||||
|
|
||||||
|
@ -105,11 +104,10 @@ A :i[lovely] language know as :abbr[HTML]{title="HyperText Markup Language"}.
|
||||||
…and our module `example.js` contains:
|
…and our module `example.js` contains:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/**
|
// Register `hName`, `hProperties` types, used when turning markdown to HTML:
|
||||||
* @import {} from 'mdast-util-directive'
|
/// <reference types="mdast-util-to-hast" />
|
||||||
* @import {} from 'mdast-util-to-hast'
|
// Register directive nodes in mdast:
|
||||||
* @import {Root} from 'mdast'
|
/// <reference types="mdast-util-directive" />
|
||||||
*/
|
|
||||||
|
|
||||||
import {h} from 'hastscript'
|
import {h} from 'hastscript'
|
||||||
import rehypeFormat from 'rehype-format'
|
import rehypeFormat from 'rehype-format'
|
||||||
|
@ -137,7 +135,7 @@ console.log(String(file))
|
||||||
// See below for others examples.
|
// See below for others examples.
|
||||||
function myRemarkPlugin() {
|
function myRemarkPlugin() {
|
||||||
/**
|
/**
|
||||||
* @param {Root} tree
|
* @param {import('mdast').Root} tree
|
||||||
* Tree.
|
* Tree.
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
* Nothing.
|
* Nothing.
|
||||||
|
@ -175,14 +173,13 @@ function myRemarkPlugin() {
|
||||||
This package exports no identifiers.
|
This package exports no identifiers.
|
||||||
The default export is [`remarkDirective`][api-remark-directive].
|
The default export is [`remarkDirective`][api-remark-directive].
|
||||||
|
|
||||||
### `unified().use(remarkDirective[, options])`
|
### `unified().use(remarkDirective)`
|
||||||
|
|
||||||
Add support for generic directives.
|
Add support for generic directives.
|
||||||
|
|
||||||
###### Parameters
|
###### Parameters
|
||||||
|
|
||||||
* `options` ([`Options`][api-options], optional)
|
There are no parameters.
|
||||||
— configuration
|
|
||||||
|
|
||||||
###### Returns
|
###### Returns
|
||||||
|
|
||||||
|
@ -193,29 +190,6 @@ Nothing (`undefined`).
|
||||||
Doesn’t handle the directives:
|
Doesn’t handle the directives:
|
||||||
[create your own plugin][unified-create-plugin] to do that.
|
[create your own plugin][unified-create-plugin] to do that.
|
||||||
|
|
||||||
### `Options`
|
|
||||||
|
|
||||||
Configuration (TypeScript type).
|
|
||||||
|
|
||||||
###### Fields
|
|
||||||
|
|
||||||
* `collapseEmptyAttributes`
|
|
||||||
(`boolean`, default: `true`)
|
|
||||||
— collapse empty attributes: get `title` instead of `title=""`
|
|
||||||
* `preferShortcut`
|
|
||||||
(`boolean`, default: `true`)
|
|
||||||
— prefer `#` and `.` shortcuts for `id` and `class`
|
|
||||||
* `preferUnquoted`
|
|
||||||
(`boolean`, default: `false`)
|
|
||||||
— leave attributes unquoted if that results in less bytes
|
|
||||||
* `quoteSmart`
|
|
||||||
(`boolean`, default: `false`)
|
|
||||||
— use the other quote if that results in less bytes
|
|
||||||
* `quote`
|
|
||||||
(`'"'` or `"'"`,
|
|
||||||
default: the [`quote`][quote] used by `remark-stringify` for titles)
|
|
||||||
— preferred quote to use around attribute values
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Example: YouTube
|
### Example: YouTube
|
||||||
|
@ -225,21 +199,19 @@ It’s based on the example in Use above.
|
||||||
If `myRemarkPlugin` was replaced with this function:
|
If `myRemarkPlugin` was replaced with this function:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/**
|
// Register `hName`, `hProperties` types, used when turning markdown to HTML:
|
||||||
* @import {} from 'mdast-util-directive'
|
/// <reference types="mdast-util-to-hast" />
|
||||||
* @import {} from 'mdast-util-to-hast'
|
// Register directive nodes in mdast:
|
||||||
* @import {Root} from 'mdast'
|
/// <reference types="mdast-util-directive" />
|
||||||
* @import {VFile} from 'vfile'
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {visit} from 'unist-util-visit'
|
import {visit} from 'unist-util-visit'
|
||||||
|
|
||||||
// This plugin is an example to turn `::youtube` into iframes.
|
// This plugin is an example to turn `::youtube` into iframes.
|
||||||
function myRemarkPlugin() {
|
function myRemarkPlugin() {
|
||||||
/**
|
/**
|
||||||
* @param {Root} tree
|
* @param {import('mdast').Root} tree
|
||||||
* Tree.
|
* Tree.
|
||||||
* @param {VFile} file
|
* @param {import('vfile').VFile} file
|
||||||
* File.
|
* File.
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
* Nothing.
|
* Nothing.
|
||||||
|
@ -307,20 +279,20 @@ It’s based on the example in Use above.
|
||||||
If `myRemarkPlugin` was replaced with this function:
|
If `myRemarkPlugin` was replaced with this function:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/**
|
// Register `hName`, `hProperties` types, used when turning markdown to HTML:
|
||||||
* @import {} from 'mdast-util-directive'
|
/// <reference types="mdast-util-to-hast" />
|
||||||
* @import {} from 'mdast-util-to-hast'
|
// Register directive nodes in mdast:
|
||||||
* @import {Root} from 'mdast'
|
/// <reference types="mdast-util-directive" />
|
||||||
*/
|
|
||||||
|
|
||||||
import {h} from 'hastscript'
|
import {h} from 'hastscript'
|
||||||
import {visit} from 'unist-util-visit'
|
import {visit} from 'unist-util-visit'
|
||||||
|
|
||||||
|
// This plugin is an example to turn `::youtube` into iframes.
|
||||||
// This plugin is an example to turn `::note` into divs, passing arbitrary
|
// This plugin is an example to turn `::note` into divs, passing arbitrary
|
||||||
// attributes.
|
// attributes.
|
||||||
function myRemarkPlugin() {
|
function myRemarkPlugin() {
|
||||||
/**
|
/**
|
||||||
* @param {Root} tree
|
* @param {import('mdast').Root} tree
|
||||||
* Tree.
|
* Tree.
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
* Nothing.
|
* Nothing.
|
||||||
|
@ -401,16 +373,14 @@ If you’re working with the syntax tree, you can register the new node types
|
||||||
with `@types/mdast` by adding a reference:
|
with `@types/mdast` by adding a reference:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/**
|
// Register directive nodes in mdast:
|
||||||
* @import {} from 'mdast-util-directive'
|
/// <reference types="mdast-util-directive" />
|
||||||
* @import {Root} from 'mdast'
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {visit} from 'unist-util-visit'
|
import {visit} from 'unist-util-visit'
|
||||||
|
|
||||||
function myRemarkPlugin() {
|
function myRemarkPlugin() {
|
||||||
/**
|
/**
|
||||||
* @param {Root} tree
|
* @param {import('mdast').Root} tree
|
||||||
* Tree.
|
* Tree.
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
* Nothing.
|
* Nothing.
|
||||||
|
@ -441,15 +411,15 @@ attacks.
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
||||||
* [`remark-gfm`](https://github.com/remarkjs/remark-gfm)
|
* [`remark-gfm`](https://github.com/remarkjs/remark-gfm)
|
||||||
— support GFM (autolink literals, footnotes, strikethrough, tables,
|
— support GFM (autolink literals, footnotes, strikethrough, tables,
|
||||||
tasklists)
|
tasklists)
|
||||||
* [`remark-frontmatter`](https://github.com/remarkjs/remark-frontmatter)
|
* [`remark-frontmatter`](https://github.com/remarkjs/remark-frontmatter)
|
||||||
— support frontmatter (YAML, TOML, and more)
|
— support frontmatter (YAML, TOML, and more)
|
||||||
* [`remark-math`](https://github.com/remarkjs/remark-math)
|
* [`remark-math`](https://github.com/remarkjs/remark-math)
|
||||||
— support math
|
— support math
|
||||||
* [`remark-mdx`](https://github.com/mdx-js/mdx/tree/main/packages/remark-mdx)
|
* [`remark-mdx`](https://github.com/mdx-js/mdx/tree/main/packages/remark-mdx)
|
||||||
— support MDX (ESM, JSX, expressions)
|
— support MDX (ESM, JSX, expressions)
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
|
@ -525,8 +495,6 @@ abide by its terms.
|
||||||
|
|
||||||
[micromark-extending-markdown]: https://github.com/micromark/micromark#extending-markdown
|
[micromark-extending-markdown]: https://github.com/micromark/micromark#extending-markdown
|
||||||
|
|
||||||
[quote]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options
|
|
||||||
|
|
||||||
[rehype]: https://github.com/rehypejs/rehype
|
[rehype]: https://github.com/rehypejs/rehype
|
||||||
|
|
||||||
[remark]: https://github.com/remarkjs/remark
|
[remark]: https://github.com/remarkjs/remark
|
||||||
|
@ -539,6 +507,4 @@ abide by its terms.
|
||||||
|
|
||||||
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||||
|
|
||||||
[api-remark-directive]: #unifieduseremarkdirective-options
|
[api-remark-directive]: #unifieduseremarkdirective
|
||||||
|
|
||||||
[api-options]: #options
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ test('fixtures', async function (t) {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
let output
|
let output
|
||||||
|
|
||||||
const processor = remark().use(remarkDirective)
|
const proc = remark().use(remarkDirective)
|
||||||
const actual = processor.parse(input)
|
const actual = proc.parse(input)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
output = String(await fs.readFile(outputUrl))
|
output = String(await fs.readFile(outputUrl))
|
||||||
|
@ -72,7 +72,7 @@ test('fixtures', async function (t) {
|
||||||
|
|
||||||
assert.deepEqual(actual, expected)
|
assert.deepEqual(actual, expected)
|
||||||
|
|
||||||
assert.equal(String(await processor.process(input)), String(output))
|
assert.equal(String(await proc.process(input)), String(output))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"customConditions": ["development"],
|
"customConditions": ["development"],
|
||||||
"declarationMap": true,
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": true,
|
||||||
"exactOptionalPropertyTypes": true,
|
"exactOptionalPropertyTypes": true,
|
||||||
|
@ -12,5 +11,5 @@
|
||||||
"target": "es2022"
|
"target": "es2022"
|
||||||
},
|
},
|
||||||
"exclude": ["coverage/", "node_modules/"],
|
"exclude": ["coverage/", "node_modules/"],
|
||||||
"include": ["**/*.js", "index.d.ts"]
|
"include": ["**/*.js"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue