satorigear 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -15
- package/README.md +157 -0
- package/dist/index.d.mts +113 -2
- package/dist/index.mjs +5663 -0
- package/package.json +20 -26
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
package/LICENSE
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025-present KazariEX
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
this software and associated documentation files (the
|
|
7
|
-
the Software without restriction, including without limitation the rights
|
|
8
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
Software, and to permit persons to whom the Software is
|
|
10
|
-
subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
奔走も虚しく、技術・流通を手に入れた地霊殿は、兵器の開発に乗り出した。
|
|
2
|
+
|
|
3
|
+
その兵器の名は——
|
|
4
|
+
|
|
5
|
+
<h1 align="center">サトリギア</h1>
|
|
6
|
+
|
|
7
|
+
<pre align="center">🧪 Working in Progress</pre>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/satorigear"><img
|
|
11
|
+
src="https://img.shields.io/npm/v/satorigear?color=EA7FA0&labelColor=232122"
|
|
12
|
+
alt="[version]"
|
|
13
|
+
></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/satorigear"><img
|
|
15
|
+
src="https://img.shields.io/npm/dm/satorigear?color=EA7FA0&labelColor=232122"
|
|
16
|
+
alt="[downloads]"
|
|
17
|
+
></a>
|
|
18
|
+
<a href="https://github.com/KazariEX/satorigear/blob/main/LICENSE"><img
|
|
19
|
+
src="https://img.shields.io/github/license/KazariEX/satorigear?color=EA7FA0&labelColor=232122"
|
|
20
|
+
alt="[license]"
|
|
21
|
+
></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
SatoriGear is a blazing fast markdown parser with full incremental support that outputs MDAST.
|
|
25
|
+
|
|
26
|
+
It includes built-in support for GFM and MDC syntax and is fully compliant with the CommonMark specification. The plugin API is not yet public.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm i satorigear
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { createParser } from "satorigear";
|
|
38
|
+
|
|
39
|
+
const parser = createParser({
|
|
40
|
+
features: {
|
|
41
|
+
attributes: true,
|
|
42
|
+
component: true,
|
|
43
|
+
footnote: true,
|
|
44
|
+
frontmatter: true,
|
|
45
|
+
math: true,
|
|
46
|
+
strikethrough: true,
|
|
47
|
+
table: true,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// one-shot parse
|
|
52
|
+
const mdast = parser.parse("...");
|
|
53
|
+
|
|
54
|
+
// incremental edit
|
|
55
|
+
const document = parser.createDocument("...");
|
|
56
|
+
document.edit([
|
|
57
|
+
{ start: 66, end: 66, text: ":" },
|
|
58
|
+
{ start: 67, end: 67, text: "nuxt-img" },
|
|
59
|
+
]);
|
|
60
|
+
const mdast = document.snapthot();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Performance
|
|
64
|
+
|
|
65
|
+
Benchmarked against Sätteri and Remark, which also produce MDAST, with feature sets kept as equivalent as possible for each profile. Since Sätteri's `markdownToMdast` returns a lazily materialized tree, parse-only and fully materialized results are reported separately.
|
|
66
|
+
|
|
67
|
+
<!-- benchmark:start environment -->
|
|
68
|
+
|
|
69
|
+
> Median of 5 mean-time runs at commit [`8055594`](https://github.com/KazariEX/satorigear/commit/8055594e0e201567e975453a991c81a62a90bce7) on Apple M3, node 26.5.0, arm64-darwin. Comparisons are relative to SatoriGear (↑ faster, ↓ slower); lower time and higher throughput are better.
|
|
70
|
+
|
|
71
|
+
<!-- benchmark:end -->
|
|
72
|
+
|
|
73
|
+
<!-- benchmark:start parse only -->
|
|
74
|
+
|
|
75
|
+
<details>
|
|
76
|
+
<summary><strong>Parse only</strong></summary>
|
|
77
|
+
|
|
78
|
+
#### CommonMark
|
|
79
|
+
|
|
80
|
+
##### CommonMark 0.31.2 specification, 205025 bytes, 1 document
|
|
81
|
+
|
|
82
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
83
|
+
| --- | ---: | ---: | ---: |
|
|
84
|
+
| **SatoriGear** | 2.62 ms | baseline | 74.6 MiB/s |
|
|
85
|
+
| Sätteri | 1.12 ms | ↑ 2.34× | 175 MiB/s |
|
|
86
|
+
| Remark | 63.1 ms | ↓ 24.08× | 3.10 MiB/s |
|
|
87
|
+
|
|
88
|
+
##### CommonMark 0.31.2 examples, 14919 bytes, 652 documents
|
|
89
|
+
|
|
90
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
91
|
+
| --- | ---: | ---: | ---: |
|
|
92
|
+
| **SatoriGear** | 1.23 ms | baseline | 11.6 MiB/s |
|
|
93
|
+
| Sätteri | 2.74 ms | ↓ 2.23× | 5.20 MiB/s |
|
|
94
|
+
| Remark | 27.0 ms | ↓ 22.02× | 0.53 MiB/s |
|
|
95
|
+
|
|
96
|
+
#### Built-in features
|
|
97
|
+
|
|
98
|
+
##### Rust release history, 910115 bytes, 1 document
|
|
99
|
+
|
|
100
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
101
|
+
| --- | ---: | ---: | ---: |
|
|
102
|
+
| **SatoriGear** | 28.0 ms | baseline | 31.1 MiB/s |
|
|
103
|
+
| Sätteri | 26.6 ms | ↑ 1.05× | 32.6 MiB/s |
|
|
104
|
+
|
|
105
|
+
##### Public APIs README, 232580 bytes, 1 document
|
|
106
|
+
|
|
107
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
108
|
+
| --- | ---: | ---: | ---: |
|
|
109
|
+
| **SatoriGear** | 8.14 ms | baseline | 27.3 MiB/s |
|
|
110
|
+
| Sätteri | 2.41 ms | ↑ 3.38× | 92.2 MiB/s |
|
|
111
|
+
|
|
112
|
+
</details>
|
|
113
|
+
|
|
114
|
+
<!-- benchmark:end -->
|
|
115
|
+
|
|
116
|
+
<!-- benchmark:start fully materialized -->
|
|
117
|
+
|
|
118
|
+
<details>
|
|
119
|
+
<summary><strong>Fully materialized</strong></summary>
|
|
120
|
+
|
|
121
|
+
#### CommonMark
|
|
122
|
+
|
|
123
|
+
##### CommonMark 0.31.2 specification, 205025 bytes, 1 document
|
|
124
|
+
|
|
125
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
126
|
+
| --- | ---: | ---: | ---: |
|
|
127
|
+
| **SatoriGear** | 2.73 ms | baseline | 71.7 MiB/s |
|
|
128
|
+
| Sätteri | 5.49 ms | ↓ 2.01× | 35.6 MiB/s |
|
|
129
|
+
| Remark | 60.0 ms | ↓ 22.01× | 3.26 MiB/s |
|
|
130
|
+
|
|
131
|
+
##### CommonMark 0.31.2 examples, 14919 bytes, 652 documents
|
|
132
|
+
|
|
133
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
134
|
+
| --- | ---: | ---: | ---: |
|
|
135
|
+
| **SatoriGear** | 1.28 ms | baseline | 11.1 MiB/s |
|
|
136
|
+
| Sätteri | 5.93 ms | ↓ 4.63× | 2.40 MiB/s |
|
|
137
|
+
| Remark | 27.1 ms | ↓ 21.12× | 0.53 MiB/s |
|
|
138
|
+
|
|
139
|
+
#### Built-in features
|
|
140
|
+
|
|
141
|
+
##### Rust release history, 910115 bytes, 1 document
|
|
142
|
+
|
|
143
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
144
|
+
| --- | ---: | ---: | ---: |
|
|
145
|
+
| **SatoriGear** | 28.1 ms | baseline | 30.9 MiB/s |
|
|
146
|
+
| Sätteri | 77.3 ms | ↓ 2.75× | 11.2 MiB/s |
|
|
147
|
+
|
|
148
|
+
##### Public APIs README, 232580 bytes, 1 document
|
|
149
|
+
|
|
150
|
+
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
151
|
+
| --- | ---: | ---: | ---: |
|
|
152
|
+
| **SatoriGear** | 8.84 ms | baseline | 25.1 MiB/s |
|
|
153
|
+
| Sätteri | 20.9 ms | ↓ 2.36× | 10.6 MiB/s |
|
|
154
|
+
|
|
155
|
+
</details>
|
|
156
|
+
|
|
157
|
+
<!-- benchmark:end -->
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Literal, Node, PhrasingContent, Root, RootContent } from "mdast";
|
|
2
|
+
//#region src/source-view.d.ts
|
|
3
|
+
interface SourceSpan {
|
|
4
|
+
end: number;
|
|
5
|
+
start: number;
|
|
6
|
+
}
|
|
7
|
+
interface TextEdit extends SourceSpan {
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/document.d.ts
|
|
12
|
+
interface EditResult {
|
|
13
|
+
changedSpan: SourceSpan;
|
|
14
|
+
}
|
|
15
|
+
interface Document {
|
|
16
|
+
readonly source: string;
|
|
17
|
+
edit: (edits: readonly TextEdit[]) => EditResult;
|
|
18
|
+
snapshot: () => Root;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/profile/features/formatting.d.ts
|
|
22
|
+
interface StrikethroughOptions {
|
|
23
|
+
singleTilde?: boolean;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/profile/features/frontmatter.d.ts
|
|
27
|
+
type FrontmatterMarker = "+" | "-";
|
|
28
|
+
interface FrontmatterOptions {
|
|
29
|
+
marker: FrontmatterMarker;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/profile/features/math/types.d.ts
|
|
33
|
+
interface MathOptions {
|
|
34
|
+
singleDollarTextMath?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface Math extends Literal {
|
|
37
|
+
type: "math";
|
|
38
|
+
meta: string | null;
|
|
39
|
+
}
|
|
40
|
+
interface InlineMath extends Literal {
|
|
41
|
+
type: "inlineMath";
|
|
42
|
+
}
|
|
43
|
+
declare module "mdast" {
|
|
44
|
+
interface BlockContentMap {
|
|
45
|
+
math: Math;
|
|
46
|
+
}
|
|
47
|
+
interface PhrasingContentMap {
|
|
48
|
+
inlineMath: InlineMath;
|
|
49
|
+
}
|
|
50
|
+
interface RootContentMap {
|
|
51
|
+
inlineMath: InlineMath;
|
|
52
|
+
math: Math;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/profile/index.d.ts
|
|
57
|
+
interface FeatureOptions {
|
|
58
|
+
attributes?: boolean;
|
|
59
|
+
component?: boolean;
|
|
60
|
+
footnote?: boolean;
|
|
61
|
+
frontmatter?: boolean | FrontmatterOptions;
|
|
62
|
+
math?: boolean | MathOptions;
|
|
63
|
+
strikethrough?: boolean | StrikethroughOptions;
|
|
64
|
+
table?: boolean;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/parser.d.ts
|
|
68
|
+
interface Parser {
|
|
69
|
+
createDocument: (source: string) => Document;
|
|
70
|
+
parse: (source: string) => Root;
|
|
71
|
+
}
|
|
72
|
+
interface ParserOptions {
|
|
73
|
+
features?: FeatureOptions;
|
|
74
|
+
}
|
|
75
|
+
declare function createParser(options?: ParserOptions): Parser;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/profile/features/attributes/types.d.ts
|
|
78
|
+
type AttributeValue = string | number | boolean | null | AttributeValue[] | {
|
|
79
|
+
[key: string]: AttributeValue;
|
|
80
|
+
};
|
|
81
|
+
type Attributes = Record<string, AttributeValue>;
|
|
82
|
+
declare module "mdast" {
|
|
83
|
+
interface Node {
|
|
84
|
+
attributes?: Attributes;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/profile/features/component/types.d.ts
|
|
89
|
+
interface BlockComponent extends Node {
|
|
90
|
+
type: "blockComponent";
|
|
91
|
+
name: string;
|
|
92
|
+
attributes: Attributes;
|
|
93
|
+
children: RootContent[];
|
|
94
|
+
}
|
|
95
|
+
interface InlineComponent extends Node {
|
|
96
|
+
type: "inlineComponent";
|
|
97
|
+
name: string;
|
|
98
|
+
attributes: Attributes;
|
|
99
|
+
children: PhrasingContent[];
|
|
100
|
+
}
|
|
101
|
+
declare module "mdast" {
|
|
102
|
+
interface BlockContentMap {
|
|
103
|
+
blockComponent: BlockComponent;
|
|
104
|
+
}
|
|
105
|
+
interface PhrasingContentMap {
|
|
106
|
+
inlineComponent: InlineComponent;
|
|
107
|
+
}
|
|
108
|
+
interface RootContentMap {
|
|
109
|
+
blockComponent: BlockComponent;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { type AttributeValue, type Attributes, type BlockComponent, type Document, type EditResult, type FeatureOptions, type FrontmatterMarker, type FrontmatterOptions, type InlineComponent, type InlineMath, type Math, type MathOptions, Parser, ParserOptions, type StrikethroughOptions, type TextEdit, createParser };
|