papagaio 0.2.4 → 0.2.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 CHANGED
@@ -13,10 +13,15 @@ const result = p.process(input);
13
13
  ## Configuration
14
14
 
15
15
  ```javascript
16
- p.open = "{"; // opening delimiter
17
- p.close = "}"; // closing delimiter
18
- p.sigil = "$"; // variable marker
19
- p.maxRecursion = 512; // iteration limit
16
+ p.symbols = {
17
+ pattern: "pattern", // pattern keyword
18
+ context: "context", // context keyword
19
+ open: "{", // opening delimiter
20
+ close: "}", // closing delimiter
21
+ sigil: "$" // variable marker
22
+ };
23
+ p.recursion_limit = 512; // iteration limit
24
+ p.unique_id = 0; // unique ID counter
20
25
  ```
21
26
 
22
27
  ---
@@ -65,8 +70,8 @@ $block name {open}{close}
65
70
  ### Example
66
71
 
67
72
  ```
68
- pattern {$block content {(}{)}} {[$content]}
69
- data ( hello world )
73
+ pattern {$name $block content {(}{)}} {[$content]}
74
+ data (hello world)
70
75
  ```
71
76
  Output: `[hello world]`
72
77
 
@@ -141,15 +146,21 @@ Output:
141
146
  ## Special Keywords
142
147
 
143
148
  ### $unique
144
- Generate unique incremental IDs.
149
+ Generate unique incremental IDs for each pattern call. All occurrences of `$unique` within the same pattern replacement share the same ID.
145
150
 
146
151
  ```
147
- pattern {item} {item_$unique}
152
+ pattern {item} {[$unique]item_$unique}
148
153
  item
149
154
  item
150
155
  item
151
156
  ```
152
- Output: `item_u0`, `item_u1`, `item_u2`
157
+ Output: `[0]item_0`, `[1]item_1`, `[2]item_2`
158
+
159
+ ```
160
+ pattern {a} {$unique $unique}
161
+ a
162
+ ```
163
+ Output: `0 0` (same ID for both occurrences)
153
164
 
154
165
  ### $match
155
166
  Return the full match.
@@ -164,10 +175,9 @@ Output: `FOUND: [data]`
164
175
  Text before and after the match.
165
176
 
166
177
  ```
167
- pattern {$x} {BEFORE:$prefix | AFTER:$suffix}
168
- hello world test
178
+ pattern {world} {$prefix$suffix}hello world test
169
179
  ```
170
- Output: `BEFORE: | AFTER: world test`
180
+ Output: `hello hello test test`
171
181
 
172
182
  ### $clear
173
183
  Remove everything before the match.
@@ -195,8 +205,8 @@ Output: `10`
195
205
 
196
206
  ```
197
207
  context {
198
- pattern {# $t} {<h1>$t</h1>}
199
208
  pattern {## $t} {<h2>$t</h2>}
209
+ pattern {# $t} {<h1>$t</h1>}
200
210
  pattern {**$t**} {<strong>$t</strong>}
201
211
  pattern {*$t*} {<em>$t</em>}
202
212
  pattern {- $i} {<li>$i</li>}
@@ -282,7 +292,7 @@ Output:
282
292
  | Pattern doesn't match | Use `$$` between elements for flexible whitespace |
283
293
  | Variable not captured | Check space between variables |
284
294
  | Block not working | Verify balanced delimiters `{` `}` |
285
- | Infinite recursion | Use `$clear` or reduce `maxRecursion` |
295
+ | Infinite recursion | Use `$clear` or reduce `recursion_limit` |
286
296
  | $eval not working | Errors return empty string, use try-catch |
287
297
 
288
298
  ## Known Bugs
@@ -298,7 +308,7 @@ pattern {$x $y} {$y, $x} # basic pattern
298
308
  pattern {$x$$y} {$x-$y} # flexible whitespace
299
309
  pattern {$block n {o}{c}} {$n} # block
300
310
  context { ... } # recursive scope
301
- $unique # unique ID
311
+ $unique # unique ID per pattern
302
312
  $match # full match
303
313
  $prefix / $suffix # before/after
304
314
  $clear # clear before
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "papagaio",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
4
4
  "description": "easy yet powerful preprocessor",
5
5
  "main": "src/papagaio.js",
6
6
  "type": "module",