https://github.com/heiwa4126/unified-plugin-tutorial-js1
retext のプラグインをつくってみる練習
https://github.com/heiwa4126/unified-plugin-tutorial-js1
drill plugin unified
Last synced: over 1 year ago
JSON representation
retext のプラグインをつくってみる練習
- Host: GitHub
- URL: https://github.com/heiwa4126/unified-plugin-tutorial-js1
- Owner: heiwa4126
- Created: 2023-04-25T02:08:58.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-27T02:35:21.000Z (about 3 years ago)
- Last Synced: 2025-01-04T16:18:37.319Z (over 1 year ago)
- Topics: drill, plugin, unified
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# unified-plugin-tutorial-js1
unifiedのremark/rehype pluginを作るチュートリアルをやってみた。
まず
[Create a plugin \- unified](https://unifiedjs.com/learn/guide/create-a-plugin/)
を見ながら retext のプラグインをつくってみる。
先にこれをやってから。
[Use unified - unified](https://unifiedjs.com/learn/guide/using-unified/)
[Learn - unified](https://unifiedjs.com/learn/) にづづく。
## 実行
```bash
pnpm i
```
したのち
[Use unified - unified](https://unifiedjs.com/learn/guide/using-unified/)の方は:
```bash
node index.js
```
[Create a plugin \- unified](https://unifiedjs.com/learn/guide/create-a-plugin/)の方は:
```bash
node example.js
```
(プラグインは`index.js`から`pligin1.js`に移した)
## メモ
bashの
```bash
node index.js < example.md > example.html
```
はPowershellでは
```powershell
Get-Content example.md | node index.js | Out-File example.html
# or
GC example.md | node index.js > example.html
```
↑めんどくさいので `node index.js < example.md` 相当は `pnpm start`で。
(Windowsだと`cmd.exe`で実行される)
VFileでやるのが賢い感じ。
Unifiedの既存のフィルタ、ほぼESMみたい。
たまにtypesが変なやつがあってTypeScriptだとちょっと辛い。