@the_dissidents/libemmm 0.0.2 → 0.0.3

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
@@ -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
  :--
@@ -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**]
@@ -257,11 +273,15 @@ For strange edge cases of the basic syntax and the built-in configuration, see t
257
273
  | 7 | Invalid entity in inline modifier definition
258
274
  | 8 | Reached recursion limit (<...>)
259
275
  | 9 | Slot modifier used outside a definition
276
+ | 10 | Nested module definitions not allowed
277
+ | 11 | Cannot use the same module inside its definition
278
+ | 12 | A definition cannot be at once normal and preformatted
260
279
 
261
280
  |Code|Warning|Suggestions|
262
281
  |---:|-------|-|
263
282
  | 1 |Unnecessary newline(s)| *remove*
264
- | 2 | Block should begin in a new line to avoid confusion| *add a line break*
283
+ | ~~2~~ | ~~Block should begin in a new line to avoid confusion~~| ~~*add a line break*~~
265
284
  | 3 | Content should begin in a new line to avoid confusion | *add a line break*
266
285
  | 4 | Modifier already defined, overwriting
267
286
  | 5 | Undefined variable, will expand to empty string
287
+ | 6 | Using this module will overwrite: <...>