@the_dissidents/libemmm 0.0.2 → 0.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # libemmm
2
2
 
3
- This package contains the parser and language server for the `emmm` markup language. Will include renderers in the future.
3
+ This package contains the parser and language server for the `emmm` markup language.
4
4
 
5
5
  ```sh
6
6
  npm install @the_dissidents/libemmm
@@ -28,7 +28,7 @@ let doc = emmm.parse(scanner, config);
28
28
  - `doc.messages` is the array of diagnostic messages.
29
29
  - You may want to call `doc.debugPrint(source)` to get a pretty-printed debug string of the AST.
30
30
 
31
- ## Reference to `emmm` Syntax
31
+ ## A Semi-Technical Reference to `emmm` Syntax
32
32
 
33
33
  ![AST Structure](./doc-images/ast.svg)
34
34
 
@@ -60,7 +60,7 @@ This paragraph is NOT under foo, [.foo] but this immediately starts a new one un
60
60
  [.foo] ... and this is another block of foo.
61
61
 
62
62
  [.foo]
63
- [.foo] However, this is foo inside foo, since the outer foo hasn't encountered any block before the parser met the inner foo, which became the content of the outer one.
63
+ [.foo] However, this is foo inside foo, since the outer foo hadn't encountered any block before the parser met the inner foo, which became the content of the outer one.
64
64
 
65
65
  [.foo]
66
66
  :--
@@ -164,7 +164,7 @@ A colon before the first argument states explicitly the beginning of that argume
164
164
  [**-define-inline** *name*:*args...*]
165
165
  [**-define-inline** *name*:*args...*:(*slot*)]
166
166
 
167
- > Define a new modifier. The first argument is the name. If more than one argument 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.
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
  >
169
169
  > Take content as the definition of the new modifier.
170
170
 
@@ -179,18 +179,26 @@ A colon before the first argument states explicitly the beginning of that argume
179
179
 
180
180
  > Not implemented yet
181
181
 
182
- [**-define-inline-shorthand** *opening*:*ending*:]
183
- [**-define-inline-shorthand** *opening*:(*slot*):*ending*:]
184
- [**-define-inline-shorthand** *opening*:(*slot1*):*mid1*:(*slot2*):*mid2*:(*slot3*)...:*ending*:]
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*]
185
186
 
186
- > Not implemented yet
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
+ > ```
189
+ > [-inline-shorthand:\[!:url:|:():\]:] content
190
+ > ```
191
+ > This creates: `[!` argument:url `|` slot `]`
192
+ > ```
193
+ > [-inline-shorthand:\[!:url:|:text:\]:] content
194
+ > ```
195
+ > This creates: `[!` argument:url `|` argument:text `]`
196
+ >
197
+ > Note the first shorthand has a slot, while the second doesn't. This means you can't put formatted content as text in the second shorthand.
187
198
 
188
- [**-push-notation**]
189
- [**-pop-notation**]
199
+ [**-use** *module-name*]
190
200
 
191
- > Pushes the current notation data (modifiers and shorthands) onto a stack, or pop the stack to revert to the situation before pushing.
192
- >
193
- > This is useful, for example, when you implement a `[.table]` modifier and want to have a lot of shorthands for table rows and cells etc. that only function inside this modifier. In this case, functioning everywhere just doesn't make sense and pollutes the syntax.
201
+ > Activates the definitions in a module for the whole document; see `[.use]`.
194
202
 
195
203
  ### Block modifiers
196
204
 
@@ -214,6 +222,14 @@ A colon before the first argument states explicitly the beginning of that argume
214
222
  > ```
215
223
  > Note the first, unnamed `.slot` refers to the slot of `q`.
216
224
 
225
+ [**.module** *module-name*]
226
+
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
+
229
+ [**.use** *module-name*]
230
+
231
+ > Activates the definitions in a module for the content *within this modifier*. Use `[-use]` to activate for the whole document instead.
232
+
217
233
  ### Inline modifiers
218
234
 
219
235
  [**/slot**]
@@ -245,6 +261,8 @@ For strange edge cases of the basic syntax and the built-in configuration, see t
245
261
 
246
262
  ## Diagnostic Messages
247
263
 
264
+ > Note: 'suggestions' are currently not being implemented
265
+
248
266
  |Code|Error|Suggestions|
249
267
  |---:|-----|-|
250
268
  | 1 | Syntax error: expecting <...>
@@ -257,11 +275,16 @@ For strange edge cases of the basic syntax and the built-in configuration, see t
257
275
  | 7 | Invalid entity in inline modifier definition
258
276
  | 8 | Reached recursion limit (<...>)
259
277
  | 9 | Slot modifier used outside a definition
278
+ | 10 | Nested module definitions not allowed
279
+ | 11 | Cannot use the same module inside its definition
280
+ | 12 | A definition cannot be at once normal and preformatted
260
281
 
261
282
  |Code|Warning|Suggestions|
262
283
  |---:|-------|-|
263
284
  | 1 |Unnecessary newline(s)| *remove*
264
- | 2 | Block should begin in a new line to avoid confusion| *add a line break*
285
+ | ~~2~~ | ~~Block should begin in a new line to avoid confusion~~| ~~*add a line break*~~
265
286
  | 3 | Content should begin in a new line to avoid confusion | *add a line break*
266
287
  | 4 | Modifier already defined, overwriting
267
288
  | 5 | Undefined variable, will expand to empty string
289
+ | 6 | Using this module will overwrite: <...>
290
+ | 7 | <...> is already defined (as <...>), will be overwritten