rumdl-wasm 0.0.185
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 +21 -0
- package/README.md +197 -0
- package/package.json +34 -0
- package/rumdl_lib.d.ts +84 -0
- package/rumdl_lib.js +396 -0
- package/rumdl_lib_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Ruben J. Jongejan
|
|
4
|
+
|
|
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
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
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,197 @@
|
|
|
1
|
+
# rumdl-wasm
|
|
2
|
+
|
|
3
|
+
Fast markdown linter with 60+ rules, compiled to WebAssembly.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install rumdl-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import init, { lint_markdown, apply_all_fixes } from 'rumdl-wasm';
|
|
15
|
+
|
|
16
|
+
// Initialize the WASM module
|
|
17
|
+
await init();
|
|
18
|
+
|
|
19
|
+
// Lint markdown content
|
|
20
|
+
const content = '# Hello World\n\nSome text here...';
|
|
21
|
+
const warnings = JSON.parse(lint_markdown(content));
|
|
22
|
+
|
|
23
|
+
// Apply all auto-fixes
|
|
24
|
+
const fixed = apply_all_fixes(content);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API Reference
|
|
28
|
+
|
|
29
|
+
### `init()`
|
|
30
|
+
|
|
31
|
+
Initialize the WASM module. Must be called before using other functions.
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
await init();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### `lint_markdown(content: string): string`
|
|
38
|
+
|
|
39
|
+
Lint markdown content and return warnings as JSON.
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
const warnings = JSON.parse(lint_markdown(content));
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Returns a JSON array of warnings (see Warning Format below).
|
|
46
|
+
|
|
47
|
+
### `apply_all_fixes(content: string): string`
|
|
48
|
+
|
|
49
|
+
Apply all available auto-fixes to the content.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const fixed = apply_all_fixes(content);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Returns the fixed content string.
|
|
56
|
+
|
|
57
|
+
### `apply_fix(content: string, fix_json: string): string`
|
|
58
|
+
|
|
59
|
+
Apply a single fix to the content.
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
const fix = JSON.stringify({ start: 0, end: 5, replacement: 'Hello' });
|
|
63
|
+
const fixed = apply_fix(content, fix);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `get_version(): string`
|
|
67
|
+
|
|
68
|
+
Get the rumdl version.
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
const version = get_version(); // e.g., "0.0.185"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `get_available_rules(): string`
|
|
75
|
+
|
|
76
|
+
Get list of available rules as JSON.
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
const rules = JSON.parse(get_available_rules());
|
|
80
|
+
// [{ name: "MD001", description: "Heading levels should only increment by one level at a time" }, ...]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Warning Format
|
|
84
|
+
|
|
85
|
+
Each warning object contains:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
interface Warning {
|
|
89
|
+
rule: string; // Rule name (e.g., "MD001")
|
|
90
|
+
message: string; // Warning message
|
|
91
|
+
line: number; // 1-indexed line number
|
|
92
|
+
column: number; // 1-indexed column number
|
|
93
|
+
end_line: number; // 1-indexed end line
|
|
94
|
+
end_column: number; // 1-indexed end column
|
|
95
|
+
severity: string; // "Error" or "Warning"
|
|
96
|
+
fix?: { // Optional auto-fix
|
|
97
|
+
start: number; // Byte offset start
|
|
98
|
+
end: number; // Byte offset end
|
|
99
|
+
replacement: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Browser Usage
|
|
105
|
+
|
|
106
|
+
### ES Module
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<script type="module">
|
|
110
|
+
import init, { lint_markdown } from './rumdl_wasm.js';
|
|
111
|
+
|
|
112
|
+
async function main() {
|
|
113
|
+
await init();
|
|
114
|
+
const warnings = JSON.parse(lint_markdown('# Test'));
|
|
115
|
+
console.log(warnings);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
main();
|
|
119
|
+
</script>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### With CDN (unpkg)
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<script type="module">
|
|
126
|
+
import init, { lint_markdown } from 'https://unpkg.com/rumdl-wasm/rumdl_wasm.js';
|
|
127
|
+
|
|
128
|
+
await init();
|
|
129
|
+
console.log(JSON.parse(lint_markdown('# Test')));
|
|
130
|
+
</script>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Node.js Usage
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
import init, { lint_markdown, apply_all_fixes } from 'rumdl-wasm';
|
|
137
|
+
import { readFile } from 'fs/promises';
|
|
138
|
+
|
|
139
|
+
await init();
|
|
140
|
+
|
|
141
|
+
const content = await readFile('README.md', 'utf-8');
|
|
142
|
+
const warnings = JSON.parse(lint_markdown(content));
|
|
143
|
+
|
|
144
|
+
for (const w of warnings) {
|
|
145
|
+
console.log(`${w.line}:${w.column} ${w.rule} ${w.message}`);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Bundler Usage
|
|
150
|
+
|
|
151
|
+
### Vite
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
// vite.config.js
|
|
155
|
+
export default {
|
|
156
|
+
optimizeDeps: {
|
|
157
|
+
exclude: ['rumdl-wasm']
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// main.js
|
|
164
|
+
import init, { lint_markdown } from 'rumdl-wasm';
|
|
165
|
+
|
|
166
|
+
await init();
|
|
167
|
+
const warnings = JSON.parse(lint_markdown(content));
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Webpack 5
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
// webpack.config.js
|
|
174
|
+
module.exports = {
|
|
175
|
+
experiments: {
|
|
176
|
+
asyncWebAssembly: true
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## TypeScript
|
|
182
|
+
|
|
183
|
+
TypeScript definitions are included. The package exports all functions with proper types.
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import init, { lint_markdown, apply_all_fixes, get_version } from 'rumdl-wasm';
|
|
187
|
+
|
|
188
|
+
await init();
|
|
189
|
+
|
|
190
|
+
const warnings: Warning[] = JSON.parse(lint_markdown(content));
|
|
191
|
+
const fixed: string = apply_all_fixes(content);
|
|
192
|
+
const version: string = get_version();
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rumdl-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Ruben J. Jongejan <ruben.jongejan@gmail.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "Fast markdown linter with 60+ rules - WebAssembly build",
|
|
8
|
+
"version": "0.0.185",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/rvben/rumdl"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"rumdl_lib_bg.wasm",
|
|
16
|
+
"rumdl_lib.js",
|
|
17
|
+
"rumdl_lib.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "rumdl_lib.js",
|
|
20
|
+
"homepage": "https://github.com/rvben/rumdl",
|
|
21
|
+
"types": "rumdl_lib.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"markdown",
|
|
27
|
+
"linter",
|
|
28
|
+
"wasm",
|
|
29
|
+
"webassembly",
|
|
30
|
+
"lint",
|
|
31
|
+
"markdown-linter",
|
|
32
|
+
"static-analysis"
|
|
33
|
+
]
|
|
34
|
+
}
|
package/rumdl_lib.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Get list of available rules as JSON
|
|
5
|
+
*
|
|
6
|
+
* Returns a JSON array of rule info objects, each with:
|
|
7
|
+
* - `name`: Rule name (e.g., "MD001")
|
|
8
|
+
* - `description`: Rule description
|
|
9
|
+
*/
|
|
10
|
+
export function get_available_rules(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Lint markdown content and return warnings as JSON
|
|
13
|
+
*
|
|
14
|
+
* Returns a JSON array of warnings, each with:
|
|
15
|
+
* - `rule`: Rule name (e.g., "MD001")
|
|
16
|
+
* - `message`: Warning message
|
|
17
|
+
* - `line`: 1-indexed line number
|
|
18
|
+
* - `column`: 1-indexed column number
|
|
19
|
+
* - `end_line`: 1-indexed end line
|
|
20
|
+
* - `end_column`: 1-indexed end column
|
|
21
|
+
* - `severity`: "Error" or "Warning"
|
|
22
|
+
* - `fix`: Optional fix object with `start`, `end`, `replacement`
|
|
23
|
+
*/
|
|
24
|
+
export function lint_markdown(content: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Apply all auto-fixes to the content and return the fixed content
|
|
27
|
+
*
|
|
28
|
+
* Returns the content with all available fixes applied.
|
|
29
|
+
* Uses the same fix coordinator as the CLI for consistent behavior.
|
|
30
|
+
*/
|
|
31
|
+
export function apply_all_fixes(content: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the WASM module with better panic messages
|
|
34
|
+
*/
|
|
35
|
+
export function init(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get the rumdl version
|
|
38
|
+
*/
|
|
39
|
+
export function get_version(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Apply a single fix to the content
|
|
42
|
+
*
|
|
43
|
+
* Takes a JSON-encoded fix object with `start`, `end`, `replacement` fields.
|
|
44
|
+
* Returns the content with the fix applied.
|
|
45
|
+
*/
|
|
46
|
+
export function apply_fix(content: string, fix_json: string): string;
|
|
47
|
+
|
|
48
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
49
|
+
|
|
50
|
+
export interface InitOutput {
|
|
51
|
+
readonly memory: WebAssembly.Memory;
|
|
52
|
+
readonly apply_all_fixes: (a: number, b: number, c: number) => void;
|
|
53
|
+
readonly apply_fix: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
54
|
+
readonly get_available_rules: (a: number) => void;
|
|
55
|
+
readonly get_version: (a: number) => void;
|
|
56
|
+
readonly init: () => void;
|
|
57
|
+
readonly lint_markdown: (a: number, b: number, c: number) => void;
|
|
58
|
+
readonly __wbindgen_export: (a: number, b: number, c: number) => void;
|
|
59
|
+
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
60
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
61
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
62
|
+
readonly __wbindgen_start: () => void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
66
|
+
/**
|
|
67
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
68
|
+
* a precompiled `WebAssembly.Module`.
|
|
69
|
+
*
|
|
70
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
71
|
+
*
|
|
72
|
+
* @returns {InitOutput}
|
|
73
|
+
*/
|
|
74
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
78
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
79
|
+
*
|
|
80
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<InitOutput>}
|
|
83
|
+
*/
|
|
84
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/rumdl_lib.js
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let cachedUint8ArrayMemory0 = null;
|
|
4
|
+
|
|
5
|
+
function getUint8ArrayMemory0() {
|
|
6
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
+
}
|
|
9
|
+
return cachedUint8ArrayMemory0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
+
|
|
14
|
+
cachedTextDecoder.decode();
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let heap = new Array(128).fill(undefined);
|
|
34
|
+
|
|
35
|
+
heap.push(undefined, null, true, false);
|
|
36
|
+
|
|
37
|
+
let heap_next = heap.length;
|
|
38
|
+
|
|
39
|
+
function addHeapObject(obj) {
|
|
40
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
41
|
+
const idx = heap_next;
|
|
42
|
+
heap_next = heap[idx];
|
|
43
|
+
|
|
44
|
+
heap[idx] = obj;
|
|
45
|
+
return idx;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getObject(idx) { return heap[idx]; }
|
|
49
|
+
|
|
50
|
+
let WASM_VECTOR_LEN = 0;
|
|
51
|
+
|
|
52
|
+
const cachedTextEncoder = new TextEncoder();
|
|
53
|
+
|
|
54
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
55
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
56
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
57
|
+
view.set(buf);
|
|
58
|
+
return {
|
|
59
|
+
read: arg.length,
|
|
60
|
+
written: buf.length
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
66
|
+
|
|
67
|
+
if (realloc === undefined) {
|
|
68
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
69
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
70
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
71
|
+
WASM_VECTOR_LEN = buf.length;
|
|
72
|
+
return ptr;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let len = arg.length;
|
|
76
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
77
|
+
|
|
78
|
+
const mem = getUint8ArrayMemory0();
|
|
79
|
+
|
|
80
|
+
let offset = 0;
|
|
81
|
+
|
|
82
|
+
for (; offset < len; offset++) {
|
|
83
|
+
const code = arg.charCodeAt(offset);
|
|
84
|
+
if (code > 0x7F) break;
|
|
85
|
+
mem[ptr + offset] = code;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (offset !== len) {
|
|
89
|
+
if (offset !== 0) {
|
|
90
|
+
arg = arg.slice(offset);
|
|
91
|
+
}
|
|
92
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
93
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
94
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
95
|
+
|
|
96
|
+
offset += ret.written;
|
|
97
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
WASM_VECTOR_LEN = offset;
|
|
101
|
+
return ptr;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let cachedDataViewMemory0 = null;
|
|
105
|
+
|
|
106
|
+
function getDataViewMemory0() {
|
|
107
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
108
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
109
|
+
}
|
|
110
|
+
return cachedDataViewMemory0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function dropObject(idx) {
|
|
114
|
+
if (idx < 132) return;
|
|
115
|
+
heap[idx] = heap_next;
|
|
116
|
+
heap_next = idx;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function takeObject(idx) {
|
|
120
|
+
const ret = getObject(idx);
|
|
121
|
+
dropObject(idx);
|
|
122
|
+
return ret;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get list of available rules as JSON
|
|
126
|
+
*
|
|
127
|
+
* Returns a JSON array of rule info objects, each with:
|
|
128
|
+
* - `name`: Rule name (e.g., "MD001")
|
|
129
|
+
* - `description`: Rule description
|
|
130
|
+
* @returns {string}
|
|
131
|
+
*/
|
|
132
|
+
export function get_available_rules() {
|
|
133
|
+
let deferred1_0;
|
|
134
|
+
let deferred1_1;
|
|
135
|
+
try {
|
|
136
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
137
|
+
wasm.get_available_rules(retptr);
|
|
138
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
139
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
140
|
+
deferred1_0 = r0;
|
|
141
|
+
deferred1_1 = r1;
|
|
142
|
+
return getStringFromWasm0(r0, r1);
|
|
143
|
+
} finally {
|
|
144
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
145
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Lint markdown content and return warnings as JSON
|
|
151
|
+
*
|
|
152
|
+
* Returns a JSON array of warnings, each with:
|
|
153
|
+
* - `rule`: Rule name (e.g., "MD001")
|
|
154
|
+
* - `message`: Warning message
|
|
155
|
+
* - `line`: 1-indexed line number
|
|
156
|
+
* - `column`: 1-indexed column number
|
|
157
|
+
* - `end_line`: 1-indexed end line
|
|
158
|
+
* - `end_column`: 1-indexed end column
|
|
159
|
+
* - `severity`: "Error" or "Warning"
|
|
160
|
+
* - `fix`: Optional fix object with `start`, `end`, `replacement`
|
|
161
|
+
* @param {string} content
|
|
162
|
+
* @returns {string}
|
|
163
|
+
*/
|
|
164
|
+
export function lint_markdown(content) {
|
|
165
|
+
let deferred2_0;
|
|
166
|
+
let deferred2_1;
|
|
167
|
+
try {
|
|
168
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
169
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
171
|
+
wasm.lint_markdown(retptr, ptr0, len0);
|
|
172
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
173
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
174
|
+
deferred2_0 = r0;
|
|
175
|
+
deferred2_1 = r1;
|
|
176
|
+
return getStringFromWasm0(r0, r1);
|
|
177
|
+
} finally {
|
|
178
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
179
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Apply all auto-fixes to the content and return the fixed content
|
|
185
|
+
*
|
|
186
|
+
* Returns the content with all available fixes applied.
|
|
187
|
+
* Uses the same fix coordinator as the CLI for consistent behavior.
|
|
188
|
+
* @param {string} content
|
|
189
|
+
* @returns {string}
|
|
190
|
+
*/
|
|
191
|
+
export function apply_all_fixes(content) {
|
|
192
|
+
let deferred2_0;
|
|
193
|
+
let deferred2_1;
|
|
194
|
+
try {
|
|
195
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
196
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
197
|
+
const len0 = WASM_VECTOR_LEN;
|
|
198
|
+
wasm.apply_all_fixes(retptr, ptr0, len0);
|
|
199
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
200
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
201
|
+
deferred2_0 = r0;
|
|
202
|
+
deferred2_1 = r1;
|
|
203
|
+
return getStringFromWasm0(r0, r1);
|
|
204
|
+
} finally {
|
|
205
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
206
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Initialize the WASM module with better panic messages
|
|
212
|
+
*/
|
|
213
|
+
export function init() {
|
|
214
|
+
wasm.init();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get the rumdl version
|
|
219
|
+
* @returns {string}
|
|
220
|
+
*/
|
|
221
|
+
export function get_version() {
|
|
222
|
+
let deferred1_0;
|
|
223
|
+
let deferred1_1;
|
|
224
|
+
try {
|
|
225
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
226
|
+
wasm.get_version(retptr);
|
|
227
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
228
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
229
|
+
deferred1_0 = r0;
|
|
230
|
+
deferred1_1 = r1;
|
|
231
|
+
return getStringFromWasm0(r0, r1);
|
|
232
|
+
} finally {
|
|
233
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
234
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Apply a single fix to the content
|
|
240
|
+
*
|
|
241
|
+
* Takes a JSON-encoded fix object with `start`, `end`, `replacement` fields.
|
|
242
|
+
* Returns the content with the fix applied.
|
|
243
|
+
* @param {string} content
|
|
244
|
+
* @param {string} fix_json
|
|
245
|
+
* @returns {string}
|
|
246
|
+
*/
|
|
247
|
+
export function apply_fix(content, fix_json) {
|
|
248
|
+
let deferred3_0;
|
|
249
|
+
let deferred3_1;
|
|
250
|
+
try {
|
|
251
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
252
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
253
|
+
const len0 = WASM_VECTOR_LEN;
|
|
254
|
+
const ptr1 = passStringToWasm0(fix_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
255
|
+
const len1 = WASM_VECTOR_LEN;
|
|
256
|
+
wasm.apply_fix(retptr, ptr0, len0, ptr1, len1);
|
|
257
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
258
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
259
|
+
deferred3_0 = r0;
|
|
260
|
+
deferred3_1 = r1;
|
|
261
|
+
return getStringFromWasm0(r0, r1);
|
|
262
|
+
} finally {
|
|
263
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
264
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
269
|
+
|
|
270
|
+
async function __wbg_load(module, imports) {
|
|
271
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
272
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
273
|
+
try {
|
|
274
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
275
|
+
|
|
276
|
+
} catch (e) {
|
|
277
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
278
|
+
|
|
279
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
280
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
281
|
+
|
|
282
|
+
} else {
|
|
283
|
+
throw e;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const bytes = await module.arrayBuffer();
|
|
289
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
290
|
+
|
|
291
|
+
} else {
|
|
292
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
293
|
+
|
|
294
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
295
|
+
return { instance, module };
|
|
296
|
+
|
|
297
|
+
} else {
|
|
298
|
+
return instance;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function __wbg_get_imports() {
|
|
304
|
+
const imports = {};
|
|
305
|
+
imports.wbg = {};
|
|
306
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
307
|
+
let deferred0_0;
|
|
308
|
+
let deferred0_1;
|
|
309
|
+
try {
|
|
310
|
+
deferred0_0 = arg0;
|
|
311
|
+
deferred0_1 = arg1;
|
|
312
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
313
|
+
} finally {
|
|
314
|
+
wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
318
|
+
const ret = new Error();
|
|
319
|
+
return addHeapObject(ret);
|
|
320
|
+
};
|
|
321
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
322
|
+
const ret = getObject(arg1).stack;
|
|
323
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
324
|
+
const len1 = WASM_VECTOR_LEN;
|
|
325
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
326
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
327
|
+
};
|
|
328
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
329
|
+
takeObject(arg0);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
return imports;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function __wbg_finalize_init(instance, module) {
|
|
336
|
+
wasm = instance.exports;
|
|
337
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
338
|
+
cachedDataViewMemory0 = null;
|
|
339
|
+
cachedUint8ArrayMemory0 = null;
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
wasm.__wbindgen_start();
|
|
343
|
+
return wasm;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function initSync(module) {
|
|
347
|
+
if (wasm !== undefined) return wasm;
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
if (typeof module !== 'undefined') {
|
|
351
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
352
|
+
({module} = module)
|
|
353
|
+
} else {
|
|
354
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const imports = __wbg_get_imports();
|
|
359
|
+
|
|
360
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
361
|
+
module = new WebAssembly.Module(module);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
365
|
+
|
|
366
|
+
return __wbg_finalize_init(instance, module);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function __wbg_init(module_or_path) {
|
|
370
|
+
if (wasm !== undefined) return wasm;
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
if (typeof module_or_path !== 'undefined') {
|
|
374
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
375
|
+
({module_or_path} = module_or_path)
|
|
376
|
+
} else {
|
|
377
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (typeof module_or_path === 'undefined') {
|
|
382
|
+
module_or_path = new URL('rumdl_lib_bg.wasm', import.meta.url);
|
|
383
|
+
}
|
|
384
|
+
const imports = __wbg_get_imports();
|
|
385
|
+
|
|
386
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
387
|
+
module_or_path = fetch(module_or_path);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
391
|
+
|
|
392
|
+
return __wbg_finalize_init(instance, module);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export { initSync };
|
|
396
|
+
export default __wbg_init;
|
|
Binary file
|