@the_dissidents/libemmm 0.0.5 → 0.0.7
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/README.md +28 -15
- package/dist/index.d.mts +75 -21
- package/dist/index.d.ts +75 -21
- package/dist/index.js +259 -78
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/src/builtin/builtin.d.ts +0 -2
- package/dist/src/builtin/builtin.js +0 -18
- package/dist/src/builtin/builtin.js.map +0 -1
- package/dist/src/builtin/define-modifier.d.ts +0 -12
- package/dist/src/builtin/define-modifier.js +0 -129
- package/dist/src/builtin/define-modifier.js.map +0 -1
- package/dist/src/builtin/define-shorthand.d.ts +0 -14
- package/dist/src/builtin/define-shorthand.js +0 -178
- package/dist/src/builtin/define-shorthand.js.map +0 -1
- package/dist/src/builtin/internal.d.ts +0 -41
- package/dist/src/builtin/internal.js +0 -106
- package/dist/src/builtin/internal.js.map +0 -1
- package/dist/src/builtin/module.d.ts +0 -16
- package/dist/src/builtin/module.js +0 -156
- package/dist/src/builtin/module.js.map +0 -1
- package/dist/src/builtin/slot.d.ts +0 -7
- package/dist/src/builtin/slot.js +0 -136
- package/dist/src/builtin/slot.js.map +0 -1
- package/dist/src/builtin/var.d.ts +0 -12
- package/dist/src/builtin/var.js +0 -103
- package/dist/src/builtin/var.js.map +0 -1
- package/dist/src/debug-print.d.ts +0 -14
- package/dist/src/debug-print.js +0 -113
- package/dist/src/debug-print.js.map +0 -1
- package/dist/src/debug.d.ts +0 -15
- package/dist/src/debug.js +0 -47
- package/dist/src/debug.js.map +0 -1
- package/dist/src/default/bullets.d.ts +0 -4
- package/dist/src/default/bullets.js +0 -39
- package/dist/src/default/bullets.js.map +0 -1
- package/dist/src/default/code.d.ts +0 -6
- package/dist/src/default/code.js +0 -13
- package/dist/src/default/code.js.map +0 -1
- package/dist/src/default/default.d.ts +0 -2
- package/dist/src/default/default.js +0 -20
- package/dist/src/default/default.js.map +0 -1
- package/dist/src/default/headings.d.ts +0 -20
- package/dist/src/default/headings.js +0 -125
- package/dist/src/default/headings.js.map +0 -1
- package/dist/src/default/html-renderer.d.ts +0 -26
- package/dist/src/default/html-renderer.js +0 -108
- package/dist/src/default/html-renderer.js.map +0 -1
- package/dist/src/default/inline-styles.d.ts +0 -4
- package/dist/src/default/inline-styles.js +0 -24
- package/dist/src/default/inline-styles.js.map +0 -1
- package/dist/src/default/misc.d.ts +0 -6
- package/dist/src/default/misc.js +0 -112
- package/dist/src/default/misc.js.map +0 -1
- package/dist/src/default/notes.d.ts +0 -28
- package/dist/src/default/notes.js +0 -109
- package/dist/src/default/notes.js.map +0 -1
- package/dist/src/default/quotes.d.ts +0 -4
- package/dist/src/default/quotes.js +0 -36
- package/dist/src/default/quotes.js.map +0 -1
- package/dist/src/default/vars.d.ts +0 -2
- package/dist/src/default/vars.js +0 -39
- package/dist/src/default/vars.js.map +0 -1
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.js +0 -58
- package/dist/src/index.js.map +0 -1
- package/dist/src/interface.d.ts +0 -174
- package/dist/src/interface.js +0 -93
- package/dist/src/interface.js.map +0 -1
- package/dist/src/messages.d.ts +0 -165
- package/dist/src/messages.js +0 -279
- package/dist/src/messages.js.map +0 -1
- package/dist/src/modifier-helper.d.ts +0 -6
- package/dist/src/modifier-helper.js +0 -113
- package/dist/src/modifier-helper.js.map +0 -1
- package/dist/src/parser-config.d.ts +0 -44
- package/dist/src/parser-config.js +0 -67
- package/dist/src/parser-config.js.map +0 -1
- package/dist/src/parser.d.ts +0 -3
- package/dist/src/parser.js +0 -652
- package/dist/src/parser.js.map +0 -1
- package/dist/src/renderer.d.ts +0 -49
- package/dist/src/renderer.js +0 -81
- package/dist/src/renderer.js.map +0 -1
- package/dist/src/scanner.d.ts +0 -22
- package/dist/src/scanner.js +0 -50
- package/dist/src/scanner.js.map +0 -1
- package/dist/src/temp.d.ts +0 -1
- package/dist/src/temp.js +0 -108
- package/dist/src/temp.js.map +0 -1
- package/dist/src/typing-helper.d.ts +0 -7
- package/dist/src/typing-helper.js +0 -3
- package/dist/src/typing-helper.js.map +0 -1
- package/dist/src/util.d.ts +0 -29
- package/dist/src/util.js +0 -177
- package/dist/src/util.js.map +0 -1
- package/dist/tests/advanced_syntax.test.d.ts +0 -1
- package/dist/tests/advanced_syntax.test.js +0 -180
- package/dist/tests/advanced_syntax.test.js.map +0 -1
- package/dist/tests/basic_syntax.test.d.ts +0 -1
- package/dist/tests/basic_syntax.test.js +0 -431
- package/dist/tests/basic_syntax.test.js.map +0 -1
- package/dist/tests/default/headings.test.d.ts +0 -1
- package/dist/tests/default/headings.test.js +0 -90
- package/dist/tests/default/headings.test.js.map +0 -1
- package/dist/tests/define_block.test.d.ts +0 -1
- package/dist/tests/define_block.test.js +0 -209
- package/dist/tests/define_block.test.js.map +0 -1
- package/dist/tests/define_inline.test.d.ts +0 -1
- package/dist/tests/define_inline.test.js +0 -289
- package/dist/tests/define_inline.test.js.map +0 -1
- package/dist/tests/modules.test.d.ts +0 -1
- package/dist/tests/modules.test.js +0 -137
- package/dist/tests/modules.test.js.map +0 -1
- package/dist/tests/shorthands.test.d.ts +0 -1
- package/dist/tests/shorthands.test.js +0 -79
- package/dist/tests/shorthands.test.js.map +0 -1
- package/dist/tsup.config.d.ts +0 -2
- package/dist/tsup.config.js +0 -12
- package/dist/tsup.config.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -17
- package/dist/vitest.config.js.map +0 -1
package/README.md
CHANGED
|
@@ -83,9 +83,9 @@ You can also use the brackets without a modifier. However, this has little effec
|
|
|
83
83
|
Suppose the modifier `[.pre]` accepts a preformatted block:
|
|
84
84
|
|
|
85
85
|
```
|
|
86
|
-
[.pre]
|
|
86
|
+
[.pre] This is preformatted content, suitable for code and ASCII art. Always treated as plain text, even if I write [.foo] or [/foo] or \[.
|
|
87
87
|
|
|
88
|
-
However, like in a normal paragraph, a blank line creates a new block so this is no longer in the pre. Use brackets:
|
|
88
|
+
However, like in a normal paragraph, a blank line creates a new block so this is no longer in the pre. Use brackets if you don't want that:
|
|
89
89
|
|
|
90
90
|
[.pre]
|
|
91
91
|
:--
|
|
@@ -104,7 +104,7 @@ Use a `;` before `]` to signify empty content. Modifiers that don't accept conte
|
|
|
104
104
|
[.pre;]
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
In normal paragraphs, use a
|
|
107
|
+
In normal paragraphs, you can use a backslash `\` to **escape** a character immediately after it, so that it will not be interpreted as a special character (e.g. the beginning of a modifier).
|
|
108
108
|
|
|
109
109
|
**Inline modifiers** are similar to block modifiers, but occur in paragraphs. They are written as `[/baa]` or `[/baa args]`. If accepting content, use `[;]` to mark the end of their scope.
|
|
110
110
|
|
|
@@ -159,10 +159,10 @@ A colon before the first argument states explicitly the beginning of that argume
|
|
|
159
159
|
|
|
160
160
|
### System modifiers
|
|
161
161
|
|
|
162
|
-
[**-define-block** *name*:*args...*]
|
|
163
|
-
[**-define-block** *name*:*args...*:(*slot*)]
|
|
164
|
-
[**-define-inline** *name*:*args...*]
|
|
165
|
-
[**-define-inline** *name*:*args...*:(*slot*)]
|
|
162
|
+
[**-define-block** *name*:*args...*] *content*
|
|
163
|
+
[**-define-block** *name*:*args...*:(*slot*)] *content*
|
|
164
|
+
[**-define-inline** *name*:*args...*] *content*
|
|
165
|
+
[**-define-inline** *name*:*args...*:(*slot*)] *content*
|
|
166
166
|
|
|
167
167
|
> Define a new modifier. The first argument is the name. If one or more arguments exist, and the last is enclosed in `()`, it is taken as the **slot name** (more on that later). The rest in the middle are names for the arguments.
|
|
168
168
|
>
|
|
@@ -174,15 +174,15 @@ A colon before the first argument states explicitly the beginning of that argume
|
|
|
174
174
|
>
|
|
175
175
|
> You can't reassign arguments, only variables. Since arguments always take precedence over variables, "reassigning" them has no effect inside a definition and can only confuse the rest of the code.
|
|
176
176
|
|
|
177
|
-
[**-define-block-prefix** *prefix*]
|
|
178
|
-
[**-define-block-prefix** *prefix*:(*slot*)]
|
|
177
|
+
[**-define-block-prefix** *prefix*] *content*
|
|
178
|
+
[**-define-block-prefix** *prefix*:(*slot*)] *content*
|
|
179
179
|
|
|
180
180
|
> Not implemented yet
|
|
181
181
|
|
|
182
|
-
[**-define-inline-shorthand** *prefix*]
|
|
183
|
-
[**-define-inline-shorthand** *prefix*:(*slot*):*postfix*]
|
|
184
|
-
[**-define-inline-shorthand** *prefix*:*arg1*:*mid1*:*arg2*:*mid2*...]
|
|
185
|
-
[**-define-inline-shorthand** *prefix*:*arg1*:*mid1*:*arg2*:*mid2*...:(*slot*):*postfix*]
|
|
182
|
+
[**-define-inline-shorthand** *prefix*] *content*
|
|
183
|
+
[**-define-inline-shorthand** *prefix*:(*slot*):*postfix*] *content*
|
|
184
|
+
[**-define-inline-shorthand** *prefix*:*arg1*:*mid1*:*arg2*:*mid2*...] *content*
|
|
185
|
+
[**-define-inline-shorthand** *prefix*:*arg1*:*mid1*:*arg2*:*mid2*...:(*slot*):*postfix*] *content*
|
|
186
186
|
|
|
187
187
|
> Defines an inline shorthand. A shorthand notation consists of a prefix, zero or more pairs of argument and middle part, and optionally a slot and a postfix. You must specify a slot name if you want to use one, although you can specify an empty one using `()`. You may also specify an *empty* last argument, i.e. a `:` before the `]` that ends the modifier head, to make the postfix stand out better.
|
|
188
188
|
> ```
|
|
@@ -222,14 +222,22 @@ A colon before the first argument states explicitly the beginning of that argume
|
|
|
222
222
|
> ```
|
|
223
223
|
> Note the first, unnamed `.slot` refers to the slot of `q`.
|
|
224
224
|
|
|
225
|
-
[**.module** *module-name*]
|
|
225
|
+
[**.module** *module-name*] *content*
|
|
226
226
|
|
|
227
227
|
> Causes the definitions in the content to become part of a **module**. They don't take effect outside the `[.module]` modifier *unless* activated by a `[.use]` or `[-use]` modifier.
|
|
228
228
|
|
|
229
|
-
[**.use** *module-name*]
|
|
229
|
+
[**.use** *module-name*] *content*
|
|
230
230
|
|
|
231
231
|
> Activates the definitions in a module for the content *within this modifier*. Use `[-use]` to activate for the whole document instead.
|
|
232
232
|
|
|
233
|
+
[**.ifdef** *id*] *content*
|
|
234
|
+
|
|
235
|
+
> Expands to the content if the variable or argument *id* is defined, or nothing if it's not.
|
|
236
|
+
|
|
237
|
+
[**.ifndef** *id*] *content*
|
|
238
|
+
|
|
239
|
+
> Expands to the content if the variable or argument *id* is undefined, or nothing if it's defined.
|
|
240
|
+
|
|
233
241
|
### Inline modifiers
|
|
234
242
|
|
|
235
243
|
[**/slot**]
|
|
@@ -245,6 +253,11 @@ A colon before the first argument states explicitly the beginning of that argume
|
|
|
245
253
|
|
|
246
254
|
> Expands to the value of the arguments, separated by nothing, as plain text.
|
|
247
255
|
|
|
256
|
+
[**/ifdef** *id*] *content* [;]
|
|
257
|
+
[**/ifndef** *id*] *content* [;]
|
|
258
|
+
|
|
259
|
+
> See the similarly named block modifiers.
|
|
260
|
+
|
|
248
261
|
### Interpolators
|
|
249
262
|
|
|
250
263
|
**$(** *varid* **)**
|
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,35 @@ declare enum DebugLevel {
|
|
|
6
6
|
None = 4
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
type SourceDescriptor = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
};
|
|
12
|
+
interface Source extends SourceDescriptor {
|
|
13
|
+
readonly nLines: number;
|
|
14
|
+
/**
|
|
15
|
+
* Return the row- and column-index corresponding to a given location. The indices are zero-based.
|
|
16
|
+
*/
|
|
17
|
+
getRowCol(loc: number): [row: number, col: number];
|
|
18
|
+
/**
|
|
19
|
+
* Returns the position of the start of line `n` (zero-based). If `n` is zero, returns zero. If the source contains less than `n` lines, returns `Infinity`.
|
|
20
|
+
*/
|
|
21
|
+
getLineStart(n: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the content line `n`. If the source contains less than `n` lines, returns `Infinity`.
|
|
24
|
+
*/
|
|
25
|
+
getLine(n: number): string | undefined;
|
|
26
|
+
}
|
|
27
|
+
declare class StringSource implements Source {
|
|
28
|
+
private readonly src;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly nLines: number;
|
|
31
|
+
private readonly lineMap;
|
|
32
|
+
constructor(d: SourceDescriptor, src: string);
|
|
33
|
+
getRowCol(pos: number): [row: number, col: number];
|
|
34
|
+
getLineStart(n: number): number;
|
|
35
|
+
getLine(n: number): string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
9
38
|
declare class NameManager<T extends {
|
|
10
39
|
name: string;
|
|
11
40
|
}> {
|
|
@@ -43,6 +72,14 @@ declare class Document {
|
|
|
43
72
|
readonly messages: readonly Message[];
|
|
44
73
|
constructor(root: RootNode, context: ParseContext, messages: readonly Message[]);
|
|
45
74
|
toStripped(): Document;
|
|
75
|
+
/**
|
|
76
|
+
* Performs a depth-first walk of the node tree.
|
|
77
|
+
*/
|
|
78
|
+
walk(callback: (node: BlockEntity | InlineEntity | ArgumentEntity) => 'skip' | 'break' | 'continue'): void;
|
|
79
|
+
/**
|
|
80
|
+
* Gets all nodes that covers the given position, from outermost to innermost (essentially a path).
|
|
81
|
+
*/
|
|
82
|
+
resolvePosition(pos: number): (BlockEntity | InlineEntity | ArgumentEntity)[];
|
|
46
83
|
}
|
|
47
84
|
interface ReadonlyConfiguration {
|
|
48
85
|
readonly initializers: readonly ((cxt: ParseContext) => void)[];
|
|
@@ -77,12 +114,9 @@ type Message = {
|
|
|
77
114
|
readonly info: string;
|
|
78
115
|
readonly code: number;
|
|
79
116
|
};
|
|
80
|
-
type SourceDescriptor = {
|
|
81
|
-
name: string;
|
|
82
|
-
};
|
|
83
117
|
type LocationRange = {
|
|
84
118
|
original?: LocationRange;
|
|
85
|
-
source:
|
|
119
|
+
source: Source;
|
|
86
120
|
start: number;
|
|
87
121
|
end: number;
|
|
88
122
|
actualEnd?: number;
|
|
@@ -155,7 +189,7 @@ type InlineModifierNode<TState> = {
|
|
|
155
189
|
type RootNode = {
|
|
156
190
|
type: NodeType.Root;
|
|
157
191
|
content: BlockEntity[];
|
|
158
|
-
source:
|
|
192
|
+
source: Source;
|
|
159
193
|
};
|
|
160
194
|
type ModifierNode<T = any> = BlockModifierNode<T> | InlineModifierNode<T> | SystemModifierNode<T>;
|
|
161
195
|
type BlockEntity = ParagraphNode | PreNode | BlockModifierNode<any> | SystemModifierNode<any>;
|
|
@@ -187,22 +221,38 @@ declare class ModifierBase<TNode, TEntity> {
|
|
|
187
221
|
constructor(name: string, slotType?: ModifierSlotType, args?: Partial<ModifierBase<TNode, TEntity>>);
|
|
188
222
|
roleHint?: string;
|
|
189
223
|
/**
|
|
190
|
-
* If true, any modifier encountered
|
|
224
|
+
* If true, any modifier encountered inside it will *not* be expanded *during parse-content*,
|
|
225
|
+
* *unless* that modifier is `alwaysTryExpand`. In the vast majority of cases, you shouldn't
|
|
226
|
+
* be using this.
|
|
191
227
|
*/
|
|
192
228
|
delayContentExpansion: boolean;
|
|
193
229
|
/**
|
|
194
|
-
* If true, such a modifier will always be expanded whenever it is encountered, *even if*
|
|
230
|
+
* If true, such a modifier will always be expanded whenever it is encountered, *even if*
|
|
231
|
+
* contained in a modifier with `delayContentExpansion`. In the vast majority of cases,
|
|
232
|
+
* you shouldn't be using this.
|
|
195
233
|
*/
|
|
196
234
|
alwaysTryExpand: boolean;
|
|
197
|
-
/** Called before the modifier's content is parsed.
|
|
235
|
+
/** Called before the modifier's content is parsed.
|
|
236
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
237
|
+
*/
|
|
198
238
|
beforeParseContent?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
199
|
-
/** Called after the modifier's content is parsed.
|
|
239
|
+
/** Called after the modifier's content is parsed.
|
|
240
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
241
|
+
*/
|
|
200
242
|
afterParseContent?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
201
|
-
/** Called before reparsing of the expansion.
|
|
243
|
+
/** Called before reparsing of the expansion.
|
|
244
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.*/
|
|
202
245
|
beforeProcessExpansion?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
203
|
-
/** Called before reparsing of the expansion.
|
|
246
|
+
/** Called before reparsing of the expansion.
|
|
247
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.*/
|
|
204
248
|
afterProcessExpansion?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
249
|
+
/**
|
|
250
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
251
|
+
*/
|
|
205
252
|
prepareExpand?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
253
|
+
/**
|
|
254
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
255
|
+
*/
|
|
206
256
|
expand?: (node: TNode, cxt: ParseContext, immediate: boolean) => TEntity[] | undefined;
|
|
207
257
|
}
|
|
208
258
|
declare class BlockModifierDefinition<TState> extends ModifierBase<BlockModifierNode<TState>, BlockEntity> {
|
|
@@ -229,9 +279,9 @@ type InlineShorthand<TState> = Shorthand<InlineModifierDefinition<TState>>;
|
|
|
229
279
|
|
|
230
280
|
declare class SimpleScanner implements Scanner {
|
|
231
281
|
private src;
|
|
232
|
-
readonly source:
|
|
282
|
+
readonly source: Source;
|
|
233
283
|
private pos;
|
|
234
|
-
constructor(src: string,
|
|
284
|
+
constructor(src: string, sourceDesc?: SourceDescriptor);
|
|
235
285
|
position(): number;
|
|
236
286
|
isEOF(): boolean;
|
|
237
287
|
peek(str: string): boolean;
|
|
@@ -240,7 +290,7 @@ declare class SimpleScanner implements Scanner {
|
|
|
240
290
|
acceptWhitespaceChar(): string | null;
|
|
241
291
|
}
|
|
242
292
|
interface Scanner {
|
|
243
|
-
readonly source:
|
|
293
|
+
readonly source: Source;
|
|
244
294
|
position(): number;
|
|
245
295
|
isEOF(): boolean;
|
|
246
296
|
peek(str: string): boolean;
|
|
@@ -425,7 +475,7 @@ declare class UnnecessaryNewlineMessage extends RemoveThingMessage {
|
|
|
425
475
|
declare class NewBlockShouldBeOnNewlineMessage extends AddThingMessage {
|
|
426
476
|
constructor(location: LocationRange);
|
|
427
477
|
}
|
|
428
|
-
declare class
|
|
478
|
+
declare class ShouldBeOnNewlineMessage extends AddThingMessage {
|
|
429
479
|
constructor(location: LocationRange);
|
|
430
480
|
}
|
|
431
481
|
declare class NameAlreadyDefinedMessage implements Message {
|
|
@@ -468,8 +518,6 @@ type messages_CannotExpandArgumentMessage = CannotExpandArgumentMessage;
|
|
|
468
518
|
declare const messages_CannotExpandArgumentMessage: typeof CannotExpandArgumentMessage;
|
|
469
519
|
type messages_CannotUseModuleInSelfMessage = CannotUseModuleInSelfMessage;
|
|
470
520
|
declare const messages_CannotUseModuleInSelfMessage: typeof CannotUseModuleInSelfMessage;
|
|
471
|
-
type messages_ContentShouldBeOnNewlineMessage = ContentShouldBeOnNewlineMessage;
|
|
472
|
-
declare const messages_ContentShouldBeOnNewlineMessage: typeof ContentShouldBeOnNewlineMessage;
|
|
473
521
|
type messages_EitherNormalOrPreMessage = EitherNormalOrPreMessage;
|
|
474
522
|
declare const messages_EitherNormalOrPreMessage: typeof EitherNormalOrPreMessage;
|
|
475
523
|
type messages_EntityNotAllowedMessage = EntityNotAllowedMessage;
|
|
@@ -494,6 +542,8 @@ type messages_OverwriteSpecialVariableMessage = OverwriteSpecialVariableMessage;
|
|
|
494
542
|
declare const messages_OverwriteSpecialVariableMessage: typeof OverwriteSpecialVariableMessage;
|
|
495
543
|
type messages_ReachedRecursionLimitMessage = ReachedRecursionLimitMessage;
|
|
496
544
|
declare const messages_ReachedRecursionLimitMessage: typeof ReachedRecursionLimitMessage;
|
|
545
|
+
type messages_ShouldBeOnNewlineMessage = ShouldBeOnNewlineMessage;
|
|
546
|
+
declare const messages_ShouldBeOnNewlineMessage: typeof ShouldBeOnNewlineMessage;
|
|
497
547
|
type messages_SlotUsedOutsideDefinitionMessage = SlotUsedOutsideDefinitionMessage;
|
|
498
548
|
declare const messages_SlotUsedOutsideDefinitionMessage: typeof SlotUsedOutsideDefinitionMessage;
|
|
499
549
|
type messages_UnclosedInlineModifierMessage = UnclosedInlineModifierMessage;
|
|
@@ -505,7 +555,7 @@ declare const messages_UnknownModifierMessage: typeof UnknownModifierMessage;
|
|
|
505
555
|
type messages_UnnecessaryNewlineMessage = UnnecessaryNewlineMessage;
|
|
506
556
|
declare const messages_UnnecessaryNewlineMessage: typeof UnnecessaryNewlineMessage;
|
|
507
557
|
declare namespace messages {
|
|
508
|
-
export { messages_ArgumentCountMismatchMessage as ArgumentCountMismatchMessage, messages_CannotExpandArgumentMessage as CannotExpandArgumentMessage, messages_CannotUseModuleInSelfMessage as CannotUseModuleInSelfMessage,
|
|
558
|
+
export { messages_ArgumentCountMismatchMessage as ArgumentCountMismatchMessage, messages_CannotExpandArgumentMessage as CannotExpandArgumentMessage, messages_CannotUseModuleInSelfMessage as CannotUseModuleInSelfMessage, messages_EitherNormalOrPreMessage as EitherNormalOrPreMessage, messages_EntityNotAllowedMessage as EntityNotAllowedMessage, messages_ExpectedMessage as ExpectedMessage, messages_InvalidArgumentMessage as InvalidArgumentMessage, messages_MultipleBlocksNotPermittedMessage as MultipleBlocksNotPermittedMessage, messages_NameAlreadyDefinedMessage as NameAlreadyDefinedMessage, messages_NewBlockShouldBeOnNewlineMessage as NewBlockShouldBeOnNewlineMessage, messages_NoNestedModuleMessage as NoNestedModuleMessage, messages_OnlySimpleParagraphsPermittedMessage as OnlySimpleParagraphsPermittedMessage, messages_OverwriteDefinitionsMessage as OverwriteDefinitionsMessage, messages_OverwriteSpecialVariableMessage as OverwriteSpecialVariableMessage, messages_ReachedRecursionLimitMessage as ReachedRecursionLimitMessage, messages_ShouldBeOnNewlineMessage as ShouldBeOnNewlineMessage, messages_SlotUsedOutsideDefinitionMessage as SlotUsedOutsideDefinitionMessage, messages_UnclosedInlineModifierMessage as UnclosedInlineModifierMessage, messages_UndefinedVariableMessage as UndefinedVariableMessage, messages_UnknownModifierMessage as UnknownModifierMessage, messages_UnnecessaryNewlineMessage as UnnecessaryNewlineMessage };
|
|
509
559
|
}
|
|
510
560
|
|
|
511
561
|
declare const BuiltinConfiguration: ReadonlyConfiguration;
|
|
@@ -544,11 +594,15 @@ declare const debugPrint: {
|
|
|
544
594
|
blockShorthand: (x: BlockShorthand<any>) => string;
|
|
545
595
|
argument: (arg: ModifierArgument) => string;
|
|
546
596
|
node: (...nodes: (BlockEntity | InlineEntity)[]) => string;
|
|
547
|
-
message:
|
|
597
|
+
message: typeof debugPrintMsg;
|
|
598
|
+
range: typeof debugPrintRange;
|
|
548
599
|
document: typeof debugDumpDocument;
|
|
549
600
|
};
|
|
550
|
-
declare function
|
|
601
|
+
declare function debugPrintRange(loc: LocationRange, context?: number): string;
|
|
602
|
+
declare function debugPrintMsg(m: Message): string;
|
|
603
|
+
declare function debugDumpDocument(doc: Document): string;
|
|
551
604
|
|
|
605
|
+
declare const emmmVersion = "0.0.6";
|
|
552
606
|
declare function setDebugLevel(level: DebugLevel): void;
|
|
553
607
|
|
|
554
|
-
export { type ArgumentEntity, ArgumentInterpolatorDefinition, type BlockEntity, BlockModifierDefinition, type BlockModifierNode, type BlockRendererDefiniton, type BlockShorthand, BuiltinConfiguration, Configuration, DebugLevel, DefaultConfiguration, Document, type DocumentNode, type EscapedNode, type HTMLComponentPlugin, type HTMLPostprocessPlugin, HTMLRenderConfiguration, type HTMLRenderPlugin, HTMLRenderState, type HTMLRenderType, type HTMLRendererOptions, type InlineEntity, InlineModifierDefinition, type InlineModifierNode, type InlineRendererDefiniton, type InlineShorthand, type InterpolationNode, type LocationRange, type Message, MessageSeverity, type ModifierArgument, type ModifierNode, ModifierSlotType, type NodeRenderer, type NodeRendererDefinition, NodeType, type ParagraphNode, ParseContext, type ParseContextStoreDefinitions, type ParseContextStoreKey, type PreNode, type ReadonlyConfiguration, type ReadonlyRenderConfiguration, RenderConfiguration, RenderContext, type RendererType, type RootNode, type Scanner, SimpleScanner, type SourceDescriptor, SystemModifierDefinition, type SystemModifierNode, type TextNode, debugPrint, messages, parse, setDebugLevel };
|
|
608
|
+
export { type ArgumentEntity, ArgumentInterpolatorDefinition, type BlockEntity, BlockModifierDefinition, type BlockModifierNode, type BlockRendererDefiniton, type BlockShorthand, BuiltinConfiguration, Configuration, DebugLevel, DefaultConfiguration, Document, type DocumentNode, type EscapedNode, type HTMLComponentPlugin, type HTMLPostprocessPlugin, HTMLRenderConfiguration, type HTMLRenderPlugin, HTMLRenderState, type HTMLRenderType, type HTMLRendererOptions, type InlineEntity, InlineModifierDefinition, type InlineModifierNode, type InlineRendererDefiniton, type InlineShorthand, type InterpolationNode, type LocationRange, type Message, MessageSeverity, type ModifierArgument, type ModifierNode, ModifierSlotType, type NodeRenderer, type NodeRendererDefinition, NodeType, type ParagraphNode, ParseContext, type ParseContextStoreDefinitions, type ParseContextStoreKey, type PreNode, type ReadonlyConfiguration, type ReadonlyRenderConfiguration, RenderConfiguration, RenderContext, type RendererType, type RootNode, type Scanner, SimpleScanner, type Source, type SourceDescriptor, StringSource, SystemModifierDefinition, type SystemModifierNode, type TextNode, debugPrint, emmmVersion, messages, parse, setDebugLevel };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,35 @@ declare enum DebugLevel {
|
|
|
6
6
|
None = 4
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
type SourceDescriptor = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
};
|
|
12
|
+
interface Source extends SourceDescriptor {
|
|
13
|
+
readonly nLines: number;
|
|
14
|
+
/**
|
|
15
|
+
* Return the row- and column-index corresponding to a given location. The indices are zero-based.
|
|
16
|
+
*/
|
|
17
|
+
getRowCol(loc: number): [row: number, col: number];
|
|
18
|
+
/**
|
|
19
|
+
* Returns the position of the start of line `n` (zero-based). If `n` is zero, returns zero. If the source contains less than `n` lines, returns `Infinity`.
|
|
20
|
+
*/
|
|
21
|
+
getLineStart(n: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the content line `n`. If the source contains less than `n` lines, returns `Infinity`.
|
|
24
|
+
*/
|
|
25
|
+
getLine(n: number): string | undefined;
|
|
26
|
+
}
|
|
27
|
+
declare class StringSource implements Source {
|
|
28
|
+
private readonly src;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly nLines: number;
|
|
31
|
+
private readonly lineMap;
|
|
32
|
+
constructor(d: SourceDescriptor, src: string);
|
|
33
|
+
getRowCol(pos: number): [row: number, col: number];
|
|
34
|
+
getLineStart(n: number): number;
|
|
35
|
+
getLine(n: number): string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
9
38
|
declare class NameManager<T extends {
|
|
10
39
|
name: string;
|
|
11
40
|
}> {
|
|
@@ -43,6 +72,14 @@ declare class Document {
|
|
|
43
72
|
readonly messages: readonly Message[];
|
|
44
73
|
constructor(root: RootNode, context: ParseContext, messages: readonly Message[]);
|
|
45
74
|
toStripped(): Document;
|
|
75
|
+
/**
|
|
76
|
+
* Performs a depth-first walk of the node tree.
|
|
77
|
+
*/
|
|
78
|
+
walk(callback: (node: BlockEntity | InlineEntity | ArgumentEntity) => 'skip' | 'break' | 'continue'): void;
|
|
79
|
+
/**
|
|
80
|
+
* Gets all nodes that covers the given position, from outermost to innermost (essentially a path).
|
|
81
|
+
*/
|
|
82
|
+
resolvePosition(pos: number): (BlockEntity | InlineEntity | ArgumentEntity)[];
|
|
46
83
|
}
|
|
47
84
|
interface ReadonlyConfiguration {
|
|
48
85
|
readonly initializers: readonly ((cxt: ParseContext) => void)[];
|
|
@@ -77,12 +114,9 @@ type Message = {
|
|
|
77
114
|
readonly info: string;
|
|
78
115
|
readonly code: number;
|
|
79
116
|
};
|
|
80
|
-
type SourceDescriptor = {
|
|
81
|
-
name: string;
|
|
82
|
-
};
|
|
83
117
|
type LocationRange = {
|
|
84
118
|
original?: LocationRange;
|
|
85
|
-
source:
|
|
119
|
+
source: Source;
|
|
86
120
|
start: number;
|
|
87
121
|
end: number;
|
|
88
122
|
actualEnd?: number;
|
|
@@ -155,7 +189,7 @@ type InlineModifierNode<TState> = {
|
|
|
155
189
|
type RootNode = {
|
|
156
190
|
type: NodeType.Root;
|
|
157
191
|
content: BlockEntity[];
|
|
158
|
-
source:
|
|
192
|
+
source: Source;
|
|
159
193
|
};
|
|
160
194
|
type ModifierNode<T = any> = BlockModifierNode<T> | InlineModifierNode<T> | SystemModifierNode<T>;
|
|
161
195
|
type BlockEntity = ParagraphNode | PreNode | BlockModifierNode<any> | SystemModifierNode<any>;
|
|
@@ -187,22 +221,38 @@ declare class ModifierBase<TNode, TEntity> {
|
|
|
187
221
|
constructor(name: string, slotType?: ModifierSlotType, args?: Partial<ModifierBase<TNode, TEntity>>);
|
|
188
222
|
roleHint?: string;
|
|
189
223
|
/**
|
|
190
|
-
* If true, any modifier encountered
|
|
224
|
+
* If true, any modifier encountered inside it will *not* be expanded *during parse-content*,
|
|
225
|
+
* *unless* that modifier is `alwaysTryExpand`. In the vast majority of cases, you shouldn't
|
|
226
|
+
* be using this.
|
|
191
227
|
*/
|
|
192
228
|
delayContentExpansion: boolean;
|
|
193
229
|
/**
|
|
194
|
-
* If true, such a modifier will always be expanded whenever it is encountered, *even if*
|
|
230
|
+
* If true, such a modifier will always be expanded whenever it is encountered, *even if*
|
|
231
|
+
* contained in a modifier with `delayContentExpansion`. In the vast majority of cases,
|
|
232
|
+
* you shouldn't be using this.
|
|
195
233
|
*/
|
|
196
234
|
alwaysTryExpand: boolean;
|
|
197
|
-
/** Called before the modifier's content is parsed.
|
|
235
|
+
/** Called before the modifier's content is parsed.
|
|
236
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
237
|
+
*/
|
|
198
238
|
beforeParseContent?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
199
|
-
/** Called after the modifier's content is parsed.
|
|
239
|
+
/** Called after the modifier's content is parsed.
|
|
240
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
241
|
+
*/
|
|
200
242
|
afterParseContent?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
201
|
-
/** Called before reparsing of the expansion.
|
|
243
|
+
/** Called before reparsing of the expansion.
|
|
244
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.*/
|
|
202
245
|
beforeProcessExpansion?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
203
|
-
/** Called before reparsing of the expansion.
|
|
246
|
+
/** Called before reparsing of the expansion.
|
|
247
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.*/
|
|
204
248
|
afterProcessExpansion?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
249
|
+
/**
|
|
250
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
251
|
+
*/
|
|
205
252
|
prepareExpand?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
253
|
+
/**
|
|
254
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
255
|
+
*/
|
|
206
256
|
expand?: (node: TNode, cxt: ParseContext, immediate: boolean) => TEntity[] | undefined;
|
|
207
257
|
}
|
|
208
258
|
declare class BlockModifierDefinition<TState> extends ModifierBase<BlockModifierNode<TState>, BlockEntity> {
|
|
@@ -229,9 +279,9 @@ type InlineShorthand<TState> = Shorthand<InlineModifierDefinition<TState>>;
|
|
|
229
279
|
|
|
230
280
|
declare class SimpleScanner implements Scanner {
|
|
231
281
|
private src;
|
|
232
|
-
readonly source:
|
|
282
|
+
readonly source: Source;
|
|
233
283
|
private pos;
|
|
234
|
-
constructor(src: string,
|
|
284
|
+
constructor(src: string, sourceDesc?: SourceDescriptor);
|
|
235
285
|
position(): number;
|
|
236
286
|
isEOF(): boolean;
|
|
237
287
|
peek(str: string): boolean;
|
|
@@ -240,7 +290,7 @@ declare class SimpleScanner implements Scanner {
|
|
|
240
290
|
acceptWhitespaceChar(): string | null;
|
|
241
291
|
}
|
|
242
292
|
interface Scanner {
|
|
243
|
-
readonly source:
|
|
293
|
+
readonly source: Source;
|
|
244
294
|
position(): number;
|
|
245
295
|
isEOF(): boolean;
|
|
246
296
|
peek(str: string): boolean;
|
|
@@ -425,7 +475,7 @@ declare class UnnecessaryNewlineMessage extends RemoveThingMessage {
|
|
|
425
475
|
declare class NewBlockShouldBeOnNewlineMessage extends AddThingMessage {
|
|
426
476
|
constructor(location: LocationRange);
|
|
427
477
|
}
|
|
428
|
-
declare class
|
|
478
|
+
declare class ShouldBeOnNewlineMessage extends AddThingMessage {
|
|
429
479
|
constructor(location: LocationRange);
|
|
430
480
|
}
|
|
431
481
|
declare class NameAlreadyDefinedMessage implements Message {
|
|
@@ -468,8 +518,6 @@ type messages_CannotExpandArgumentMessage = CannotExpandArgumentMessage;
|
|
|
468
518
|
declare const messages_CannotExpandArgumentMessage: typeof CannotExpandArgumentMessage;
|
|
469
519
|
type messages_CannotUseModuleInSelfMessage = CannotUseModuleInSelfMessage;
|
|
470
520
|
declare const messages_CannotUseModuleInSelfMessage: typeof CannotUseModuleInSelfMessage;
|
|
471
|
-
type messages_ContentShouldBeOnNewlineMessage = ContentShouldBeOnNewlineMessage;
|
|
472
|
-
declare const messages_ContentShouldBeOnNewlineMessage: typeof ContentShouldBeOnNewlineMessage;
|
|
473
521
|
type messages_EitherNormalOrPreMessage = EitherNormalOrPreMessage;
|
|
474
522
|
declare const messages_EitherNormalOrPreMessage: typeof EitherNormalOrPreMessage;
|
|
475
523
|
type messages_EntityNotAllowedMessage = EntityNotAllowedMessage;
|
|
@@ -494,6 +542,8 @@ type messages_OverwriteSpecialVariableMessage = OverwriteSpecialVariableMessage;
|
|
|
494
542
|
declare const messages_OverwriteSpecialVariableMessage: typeof OverwriteSpecialVariableMessage;
|
|
495
543
|
type messages_ReachedRecursionLimitMessage = ReachedRecursionLimitMessage;
|
|
496
544
|
declare const messages_ReachedRecursionLimitMessage: typeof ReachedRecursionLimitMessage;
|
|
545
|
+
type messages_ShouldBeOnNewlineMessage = ShouldBeOnNewlineMessage;
|
|
546
|
+
declare const messages_ShouldBeOnNewlineMessage: typeof ShouldBeOnNewlineMessage;
|
|
497
547
|
type messages_SlotUsedOutsideDefinitionMessage = SlotUsedOutsideDefinitionMessage;
|
|
498
548
|
declare const messages_SlotUsedOutsideDefinitionMessage: typeof SlotUsedOutsideDefinitionMessage;
|
|
499
549
|
type messages_UnclosedInlineModifierMessage = UnclosedInlineModifierMessage;
|
|
@@ -505,7 +555,7 @@ declare const messages_UnknownModifierMessage: typeof UnknownModifierMessage;
|
|
|
505
555
|
type messages_UnnecessaryNewlineMessage = UnnecessaryNewlineMessage;
|
|
506
556
|
declare const messages_UnnecessaryNewlineMessage: typeof UnnecessaryNewlineMessage;
|
|
507
557
|
declare namespace messages {
|
|
508
|
-
export { messages_ArgumentCountMismatchMessage as ArgumentCountMismatchMessage, messages_CannotExpandArgumentMessage as CannotExpandArgumentMessage, messages_CannotUseModuleInSelfMessage as CannotUseModuleInSelfMessage,
|
|
558
|
+
export { messages_ArgumentCountMismatchMessage as ArgumentCountMismatchMessage, messages_CannotExpandArgumentMessage as CannotExpandArgumentMessage, messages_CannotUseModuleInSelfMessage as CannotUseModuleInSelfMessage, messages_EitherNormalOrPreMessage as EitherNormalOrPreMessage, messages_EntityNotAllowedMessage as EntityNotAllowedMessage, messages_ExpectedMessage as ExpectedMessage, messages_InvalidArgumentMessage as InvalidArgumentMessage, messages_MultipleBlocksNotPermittedMessage as MultipleBlocksNotPermittedMessage, messages_NameAlreadyDefinedMessage as NameAlreadyDefinedMessage, messages_NewBlockShouldBeOnNewlineMessage as NewBlockShouldBeOnNewlineMessage, messages_NoNestedModuleMessage as NoNestedModuleMessage, messages_OnlySimpleParagraphsPermittedMessage as OnlySimpleParagraphsPermittedMessage, messages_OverwriteDefinitionsMessage as OverwriteDefinitionsMessage, messages_OverwriteSpecialVariableMessage as OverwriteSpecialVariableMessage, messages_ReachedRecursionLimitMessage as ReachedRecursionLimitMessage, messages_ShouldBeOnNewlineMessage as ShouldBeOnNewlineMessage, messages_SlotUsedOutsideDefinitionMessage as SlotUsedOutsideDefinitionMessage, messages_UnclosedInlineModifierMessage as UnclosedInlineModifierMessage, messages_UndefinedVariableMessage as UndefinedVariableMessage, messages_UnknownModifierMessage as UnknownModifierMessage, messages_UnnecessaryNewlineMessage as UnnecessaryNewlineMessage };
|
|
509
559
|
}
|
|
510
560
|
|
|
511
561
|
declare const BuiltinConfiguration: ReadonlyConfiguration;
|
|
@@ -544,11 +594,15 @@ declare const debugPrint: {
|
|
|
544
594
|
blockShorthand: (x: BlockShorthand<any>) => string;
|
|
545
595
|
argument: (arg: ModifierArgument) => string;
|
|
546
596
|
node: (...nodes: (BlockEntity | InlineEntity)[]) => string;
|
|
547
|
-
message:
|
|
597
|
+
message: typeof debugPrintMsg;
|
|
598
|
+
range: typeof debugPrintRange;
|
|
548
599
|
document: typeof debugDumpDocument;
|
|
549
600
|
};
|
|
550
|
-
declare function
|
|
601
|
+
declare function debugPrintRange(loc: LocationRange, context?: number): string;
|
|
602
|
+
declare function debugPrintMsg(m: Message): string;
|
|
603
|
+
declare function debugDumpDocument(doc: Document): string;
|
|
551
604
|
|
|
605
|
+
declare const emmmVersion = "0.0.6";
|
|
552
606
|
declare function setDebugLevel(level: DebugLevel): void;
|
|
553
607
|
|
|
554
|
-
export { type ArgumentEntity, ArgumentInterpolatorDefinition, type BlockEntity, BlockModifierDefinition, type BlockModifierNode, type BlockRendererDefiniton, type BlockShorthand, BuiltinConfiguration, Configuration, DebugLevel, DefaultConfiguration, Document, type DocumentNode, type EscapedNode, type HTMLComponentPlugin, type HTMLPostprocessPlugin, HTMLRenderConfiguration, type HTMLRenderPlugin, HTMLRenderState, type HTMLRenderType, type HTMLRendererOptions, type InlineEntity, InlineModifierDefinition, type InlineModifierNode, type InlineRendererDefiniton, type InlineShorthand, type InterpolationNode, type LocationRange, type Message, MessageSeverity, type ModifierArgument, type ModifierNode, ModifierSlotType, type NodeRenderer, type NodeRendererDefinition, NodeType, type ParagraphNode, ParseContext, type ParseContextStoreDefinitions, type ParseContextStoreKey, type PreNode, type ReadonlyConfiguration, type ReadonlyRenderConfiguration, RenderConfiguration, RenderContext, type RendererType, type RootNode, type Scanner, SimpleScanner, type SourceDescriptor, SystemModifierDefinition, type SystemModifierNode, type TextNode, debugPrint, messages, parse, setDebugLevel };
|
|
608
|
+
export { type ArgumentEntity, ArgumentInterpolatorDefinition, type BlockEntity, BlockModifierDefinition, type BlockModifierNode, type BlockRendererDefiniton, type BlockShorthand, BuiltinConfiguration, Configuration, DebugLevel, DefaultConfiguration, Document, type DocumentNode, type EscapedNode, type HTMLComponentPlugin, type HTMLPostprocessPlugin, HTMLRenderConfiguration, type HTMLRenderPlugin, HTMLRenderState, type HTMLRenderType, type HTMLRendererOptions, type InlineEntity, InlineModifierDefinition, type InlineModifierNode, type InlineRendererDefiniton, type InlineShorthand, type InterpolationNode, type LocationRange, type Message, MessageSeverity, type ModifierArgument, type ModifierNode, ModifierSlotType, type NodeRenderer, type NodeRendererDefinition, NodeType, type ParagraphNode, ParseContext, type ParseContextStoreDefinitions, type ParseContextStoreKey, type PreNode, type ReadonlyConfiguration, type ReadonlyRenderConfiguration, RenderConfiguration, RenderContext, type RendererType, type RootNode, type Scanner, SimpleScanner, type Source, type SourceDescriptor, StringSource, SystemModifierDefinition, type SystemModifierNode, type TextNode, debugPrint, emmmVersion, messages, parse, setDebugLevel };
|