Skip to content

Commit a711118

Browse files
committed
Add a “publish a plugin” guide
Closes GH-20.
1 parent 2842d44 commit a711118

File tree

3 files changed

+145
-1
lines changed

3 files changed

+145
-1
lines changed

dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CommonMark
2929
DOM
3030
GFM
3131
HSL
32+
ISC
3233
JSDoc
3334
JSON
3435
JSX

doc/learn/publish-plugin.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
authorGithub: wooorm
3+
authorTwitter: wooorm
4+
author: Titus Wormer
5+
description: Guide that shows how to share a plugin with the world.
6+
group: guide
7+
modified: 2024-08-19
8+
published: 2024-08-19
9+
tags:
10+
- plugin
11+
- rehype
12+
- remark
13+
- retext
14+
- unified
15+
- publish
16+
title: Publish a plugin
17+
---
18+
19+
## Publish a plugin
20+
21+
This guide shows how to share a plugin with the world.
22+
23+
> Stuck?
24+
> Have an idea for another guide?
25+
> See [`support.md`][support].
26+
27+
### Contents
28+
29+
* [Intro](#intro)
30+
* [Package name](#package-name)
31+
* [npm](#npm)
32+
* [GitHub](#github)
33+
* [Export map](#export-map)
34+
* [`export default`](#export-default)
35+
* [Docs](#docs)
36+
* [Tests](#tests)
37+
* [License](#license)
38+
39+
### Intro
40+
41+
You may have a [plugin][github-unified-plugin] locally,
42+
that you use in a project,
43+
and think others might find useful too.
44+
45+
Below you’ll find some rules on how to share plugins with the world.
46+
47+
### Package name
48+
49+
The package name must be prefixed with `rehype-`, `remark-`, `retext-`, and so
50+
on.
51+
The name of the ecosystem.
52+
Use this prefix **only** for plugins.
53+
For presets, use `rehype-preset-`, `remark-preset-`, `retext-preset-`,
54+
and so on.
55+
56+
### npm
57+
58+
Plugins should be published to npm.
59+
You are free to publish them elsewhere too.
60+
61+
You should use a keyword `rehype-plugin`, `remark-plugin`, `retext-plugin`,
62+
and so on,
63+
to tag your package.
64+
65+
### GitHub
66+
67+
You may use GitHub.
68+
Or an alternative.
69+
70+
Only GitHub is crawled for the [explore][] page.
71+
You should use a topic `rehype-plugin`, `remark-plugin`, `retext-plugin`,
72+
and so on,
73+
to tag your repository.
74+
75+
### Export map
76+
77+
You must expose a plugin that can be imported from that package name.
78+
So,
79+
there must be a plugin at `rehype-some-plugin`.
80+
81+
There may be several plugins in a package.
82+
One example is [`rehype-mathjax`][github-rehype-mathjax],
83+
which has plugins exposed as `rehype-mathjax/browser`,
84+
`rehype-mathjax/chtml`,
85+
`rehype-mathjax/svg`,
86+
and `rehype-mathjax` (as an alias for `rehype-mathjax/svg`).
87+
The reason for different plugins in the same project is that they each use
88+
different code.
89+
Which impact performance and bundle size.
90+
91+
### `export default`
92+
93+
Your package must expose a plugin at the default export.
94+
It must be a function that must work when passed as `x` to `unified().use(x)`.
95+
96+
There may be different exports too.
97+
One example is [`remark-rehype`][github-remark-rehype],
98+
which also exposes useful things at
99+
`defaultFootnoteBackContent`,
100+
`defaultFootnoteBackLabel`, and
101+
`defaultHandlers`,
102+
but the plugin itself is exported as `default`.
103+
104+
### Docs
105+
106+
Write a good readme.
107+
Explain what the plugin does,
108+
when it should be used or not,
109+
how to configure it.
110+
111+
### Tests
112+
113+
Add thorough tests.
114+
Use a CI.
115+
You should test your project in all maintained versions of Node.js.
116+
117+
### License
118+
119+
Add a license.
120+
It should be MIT or ISC,
121+
as that aligns with most of the JavaScript ecosystem.
122+
It must be an open source license.
123+
124+
[explore]: /explore/
125+
126+
[github-rehype-mathjax]: https://github.com/remarkjs/remark-math/tree/main/packages/rehype-mathjax
127+
128+
[github-remark-rehype]: https://github.com/remarkjs/remark-rehype
129+
130+
[github-unified-plugin]: https://github.com/unifiedjs/unified#plugin
131+
132+
[support]: https://github.com/unifiedjs/.github/blob/main/support.md

generate/pipeline/article.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,24 @@ export const article = unified()
104104
properties: {ariaLabel: 'Link to self', className: ['anchor']}
105105
})
106106
.use(rehypeAbbreviate, {
107-
ignore: ['ATX', 'ECMAScript', 'ESLint', 'ID', 'JSDoc', 'JSX', 'MDX'],
107+
ignore: [
108+
'ATX',
109+
'ECMAScript',
110+
'ESLint',
111+
'ID',
112+
'ISC',
113+
'JSDoc',
114+
'JSX',
115+
'MDX',
116+
'MIT'
117+
],
108118
titles: {
109119
API: 'Application programming interface',
110120
ARIA: 'Accessible rich internet applications',
111121
AST: 'Abstract syntax tree',
112122
CDN: 'Content delivery network',
113123
CDATUM: 'Character data',
124+
CI: 'Continuous integration',
114125
CLI: 'Command-line interface',
115126
CSS: 'Cascading style sheets',
116127
DOM: 'Document object model',

0 commit comments

Comments
 (0)