Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
LumaKernel committed Jan 24, 2024
0 parents commit 5d26807
Show file tree
Hide file tree
Showing 64 changed files with 12,981 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-env node */
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
root: true,
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
},
};
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
on:
push:
branches: [main]
env:
NODE_VERSION:
NPM_VERSION:
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
118 changes: 118 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# luma-unified

> [!WARNING]
> このパッケージが提供するプラグインは私のユースケースに特化したものなので,直接使うのは推奨しません.
> The plugins provided by this package are specific to my use case, so I do not recommend using them directly!

## ライセンス

MITとCC0でライセンスされています

## rehype-add-slug

各ヘディングに対し,slug化したそのテキストを属性として渡し,それより上位のヘディングのslugも属性に付与するプラグイン

```ts
import rehypeAddSlug from "@luma-dev/luma-unified/rehype-add-slug";
```

例: 以下の入力に対し,

```md
# hello world

## 1. getting started

## 2. install

## 3. uninstall

# description

## 1. something

## 2. other
```

以下のように変換される

```js
<h1 slug="hello_world">hello world</h1>
<h2 lastH1Slug="hello_world" slug="1.getting_started">1. getting started</h1>
<h2 lastH1Slug="hello_world" slug="2.install">2. install</h1>
...
```

## rehype-replace-text

句点読点を統一する.「,」「.」を「、」「。」に置き換えるプラグイン.

```ts
import rehypeReplaceText from "@luma-dev/luma-unified/rehype-replace-text";
```

例: 以下の入力に対し,

```md
こんにちは,ねこだよ.
```

以下のように変換される

```md
こんにちは、ねこだよ。
```

## remark-term

用語を参照する記法を追加します.mdx前提です.

```ts
import remarkTerm from "@luma-dev/luma-unified/remark-term";
```

例: 以下の入力に対し,

```mdx
[@逆元]を考える.

{/* 以下のようにすると途中で定義を変えられる */}
<DefMapImp
逆元="群の逆元"
/>

[@逆元]を考える.

{/* 通常のリンクでは先頭の@をエスケープする必要がある */}
[\@これもリンク](https://example.com)だよ.
```

以下のように変換される

```mdx
<LumaTerm rawTermRef="逆元" termRef="逆元" gotBy="raw"/>を考える.

<LumaTerm rawTermRef="逆元" termRef="群の逆元" gotBy="imp"/>を考える.
```

`DefMapImp` (implicit) の他に `DefMapExp` (explicit) でも書き換えられる.
それらの振る舞いの違いは利用側に委ねられている.
[remark-frontmatter](https://github.com/remarkjs/remark-frontmatter)を入れた状態でfrontmatterのYAMLで `DefMapExp``DefMapImp` を使うと同様に初期化できる

```mdx
---
DefMapExp:
DefMapImp:
逆元: 行列の逆元
---
```

## rehype-katex

TODO

```ts
import rehypeKatex from "@luma-dev/luma-unified/rehype-katex";
```

3 changes: 3 additions & 0 deletions examples/es/input/ctx-delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(() => {
delete globalThis[a];
})();
3 changes: 3 additions & 0 deletions examples/es/input/ctx-push.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(() => {
globalThis[a] += "a";
})();
3 changes: 3 additions & 0 deletions examples/es/input/ctx-reset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(() => {
globalThis[a] = "";
})();
1 change: 1 addition & 0 deletions examples/es/input/ctx-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globalThis[a];
1 change: 1 addition & 0 deletions examples/es/input/make-symbol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const a = Symbol();
1 change: 1 addition & 0 deletions examples/es/input/var.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a;
68 changes: 68 additions & 0 deletions examples/es/output/ctx-delete.js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"type": "Program",
"start": 0,
"end": 39,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 38,
"expression": {
"type": "CallExpression",
"start": 0,
"end": 37,
"callee": {
"type": "ArrowFunctionExpression",
"start": 1,
"end": 34,
"id": null,
"expression": false,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 7,
"end": 34,
"body": [
{
"type": "ExpressionStatement",
"start": 11,
"end": 32,
"expression": {
"type": "UnaryExpression",
"start": 11,
"end": 31,
"operator": "delete",
"prefix": true,
"argument": {
"type": "MemberExpression",
"start": 18,
"end": 31,
"object": {
"type": "Identifier",
"start": 18,
"end": 28,
"name": "globalThis"
},
"property": {
"type": "Identifier",
"start": 29,
"end": 30,
"name": "a"
},
"computed": true,
"optional": false
}
}
}
]
}
},
"arguments": [],
"optional": false
}
}
],
"sourceType": "module"
}
74 changes: 74 additions & 0 deletions examples/es/output/ctx-push.js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"type": "Program",
"start": 0,
"end": 39,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 38,
"expression": {
"type": "CallExpression",
"start": 0,
"end": 37,
"callee": {
"type": "ArrowFunctionExpression",
"start": 1,
"end": 34,
"id": null,
"expression": false,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 7,
"end": 34,
"body": [
{
"type": "ExpressionStatement",
"start": 11,
"end": 32,
"expression": {
"type": "AssignmentExpression",
"start": 11,
"end": 31,
"operator": "+=",
"left": {
"type": "MemberExpression",
"start": 11,
"end": 24,
"object": {
"type": "Identifier",
"start": 11,
"end": 21,
"name": "globalThis"
},
"property": {
"type": "Identifier",
"start": 22,
"end": 23,
"name": "a"
},
"computed": true,
"optional": false
},
"right": {
"type": "Literal",
"start": 28,
"end": 31,
"value": "a",
"raw": "\"a\""
}
}
}
]
}
},
"arguments": [],
"optional": false
}
}
],
"sourceType": "module"
}
74 changes: 74 additions & 0 deletions examples/es/output/ctx-reset.js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"type": "Program",
"start": 0,
"end": 37,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 36,
"expression": {
"type": "CallExpression",
"start": 0,
"end": 35,
"callee": {
"type": "ArrowFunctionExpression",
"start": 1,
"end": 32,
"id": null,
"expression": false,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 7,
"end": 32,
"body": [
{
"type": "ExpressionStatement",
"start": 11,
"end": 30,
"expression": {
"type": "AssignmentExpression",
"start": 11,
"end": 29,
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 11,
"end": 24,
"object": {
"type": "Identifier",
"start": 11,
"end": 21,
"name": "globalThis"
},
"property": {
"type": "Identifier",
"start": 22,
"end": 23,
"name": "a"
},
"computed": true,
"optional": false
},
"right": {
"type": "Literal",
"start": 27,
"end": 29,
"value": "",
"raw": "\"\""
}
}
}
]
}
},
"arguments": [],
"optional": false
}
}
],
"sourceType": "module"
}
Loading

0 comments on commit 5d26807

Please sign in to comment.