@p-buddy/parkdown 0.0.14 → 0.0.20
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 +94 -42
- package/dist/cli.js +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ populateMarkdownInclusions(file, writeFile);
|
|
|
44
44
|
|
|
45
45
|
[](./.assets/authoring.md)
|
|
46
46
|
<!-- p↓ BEGIN -->
|
|
47
|
-
<!-- p↓ length lines:
|
|
47
|
+
<!-- p↓ length lines: 663 chars: 22766 -->
|
|
48
48
|
## Authoring
|
|
49
49
|
|
|
50
50
|
You author inclusions in your markdown files using a link with no text i.e. `[](<url>)`, where `<url>` points to some local or remote text resource (e.g.`./other.md`, `https://example.com/remote.md`).
|
|
@@ -256,7 +256,7 @@ Before...
|
|
|
256
256
|
|
|
257
257
|
[](.assets/query.md?heading=-1)
|
|
258
258
|
<!-- p↓ BEGIN -->
|
|
259
|
-
<!-- p↓ length lines:
|
|
259
|
+
<!-- p↓ length lines: 450 chars: 18060 -->
|
|
260
260
|
### Query parameters
|
|
261
261
|
|
|
262
262
|
You can pass query parameters to your inclusion links to control how their content is processed and included within your markdown.
|
|
@@ -265,15 +265,19 @@ You can pass query parameters to your inclusion links to control how their conte
|
|
|
265
265
|
|
|
266
266
|
[](src/include.ts?®ion=extract(query))
|
|
267
267
|
<!-- p↓ BEGIN -->
|
|
268
|
-
<!-- p↓ length lines:
|
|
268
|
+
<!-- p↓ length lines: 14 chars: 560 -->
|
|
269
269
|
|
|
270
270
|
```ts
|
|
271
271
|
const params = new URLSearchParams(query);
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const
|
|
272
|
+
const entries = (key: string) => {
|
|
273
|
+
const values = Array.from(params.entries()).filter(([k]) => k === key).map(([_, v]) => v);
|
|
274
|
+
return values.length >= 1 ? values.join(",") : undefined;
|
|
275
|
+
};
|
|
276
|
+
const regions = entries("region")?.split(COMMA_NOT_IN_PARENTHESIS);
|
|
277
|
+
const skip = params.has("skip");
|
|
278
|
+
const headingModfiier = params.get("heading") ?? 0;
|
|
279
|
+
const inlineOverride = params.has("inline");
|
|
280
|
+
const wraps = params.get("wrap")?.split(COMMA_NOT_IN_PARENTHESIS);
|
|
277
281
|
```
|
|
278
282
|
|
|
279
283
|
<!-- p↓ END -->
|
|
@@ -290,13 +294,13 @@ Specifiers will be searched for within the file's comments, and are expected to
|
|
|
290
294
|
/** some-specifier */
|
|
291
295
|
```
|
|
292
296
|
|
|
293
|
-
|
|
297
|
+
Though comment regions can be nested, it is **CRITICAL** that regions with the _same_ specifier are **NOT** nested.
|
|
298
|
+
|
|
299
|
+
Identifiers will be searched for within the text of a comment, split by spaces (i.e. `/* some-specifier */` has a single identifier, but `/* some specifier */` can be identified by either `some` or `specifier`).
|
|
294
300
|
|
|
295
301
|
Below is the currently supported API for the `region` query parameter, where each defined method signature can be _invoked_ as a value for the `region` parameter, for example:
|
|
296
302
|
|
|
297
|
-
- `[](<url>?region=
|
|
298
|
-
- `[](<url>?region=remove(some-specifier))`
|
|
299
|
-
- `[](<url>?region=replace(some-specifier,replacement-content))`
|
|
303
|
+
- `[](<url>?region=method(argument))`
|
|
300
304
|
|
|
301
305
|
If no value(s) are included (e.g. `[](<url>?region)`), then simply all comments that contain `parkdown:` or `p↓:` will be stripped (as is done as a post-processing step for all other `region` functionality).
|
|
302
306
|
|
|
@@ -316,10 +320,11 @@ Please see the [full explanation](#query-parameters-with-function-like-apis) to
|
|
|
316
320
|
|
|
317
321
|
[](src/region.ts?region=extract(definition))
|
|
318
322
|
<!-- p↓ BEGIN -->
|
|
319
|
-
<!-- p↓ length lines:
|
|
323
|
+
<!-- p↓ length lines: 122 chars: 6241 -->
|
|
320
324
|
|
|
321
325
|
```ts
|
|
322
326
|
const definitions = [
|
|
327
|
+
|
|
323
328
|
/**
|
|
324
329
|
* Extract regions from the retrieved content between comments that INCLUDE the specified ids.
|
|
325
330
|
* @param id The id of the comment to extract.
|
|
@@ -330,6 +335,7 @@ const definitions = [
|
|
|
330
335
|
* @example [](<url>?region=extract(specifier,other-specifier,some-other-specifier))
|
|
331
336
|
*/
|
|
332
337
|
"extract(id: string, 0?: string, 1?: string, 2?: string)",
|
|
338
|
+
|
|
333
339
|
/**
|
|
334
340
|
* Remove regions from the retrieved content between comments that INCLUDE the specified ids.
|
|
335
341
|
* @param id The id of the comment to remove.
|
|
@@ -340,6 +346,7 @@ const definitions = [
|
|
|
340
346
|
* @example [](<url>?region=remove(specifier,other-specifier,some-other-specifier))
|
|
341
347
|
*/
|
|
342
348
|
"remove(id: string, 0?: string, 1?: string, 2?: string)",
|
|
349
|
+
|
|
343
350
|
/**
|
|
344
351
|
* Replace regions from the retrieved content between comments that INCLUDE the specified ids.
|
|
345
352
|
* @param id The id of the comment to replace.
|
|
@@ -350,26 +357,9 @@ const definitions = [
|
|
|
350
357
|
* @example [](<url>?region=replace(specifier,new_content,_)
|
|
351
358
|
*/
|
|
352
359
|
"replace(id: string, with?: string, space?: string)",
|
|
360
|
+
|
|
353
361
|
/**
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* **NOTE:** Unlike `extract`, `remove`, and `replace`, `splice` does remove the comment from the content after processing.
|
|
357
|
-
* @param id The id of the comment regions to act on.
|
|
358
|
-
* @param deleteCount The number of characters to delete at either the beginning or end of the comment region.
|
|
359
|
-
* Specifying a number greater than or equal to 0 indicates the action should be taken at the end of the comment region.
|
|
360
|
-
* Specifying undefined or a number less than 0 indicates the action should be taken at the beginning of the comment region.
|
|
361
|
-
* @param insert The content to insert.
|
|
362
|
-
* @param space The space character to use between words in the content to insert (defaults to `-`).
|
|
363
|
-
* @example [](<url>?region=splice(specifier,-1)) // Delete one character at the beginning of the comment region.
|
|
364
|
-
* @example [](<url>?region=splice(specifier,undefined,new-content)) // Insert at the beginning of the comment region.
|
|
365
|
-
* @example [](<url>?region=splice(specifier,0,new-content)) // Insert at the end of the comment region.
|
|
366
|
-
* @example [](<url>?region=splice(specifier,1,new-content)) // Delete one character at the end of the comment region and insert.
|
|
367
|
-
*/
|
|
368
|
-
"splice(id: string, deleteCount?: number, insert?: string, space?: string)",
|
|
369
|
-
/**
|
|
370
|
-
* Remap the content within a comment region (which must INCLUDE the specified id).
|
|
371
|
-
*
|
|
372
|
-
* **NOTE:** Unlike `extract`, `remove`, and `replace`, `remap` does not remove the comment from the content after processing.
|
|
362
|
+
* Remap the content (similiar to `string.replaceAll`) within a specified comment region.
|
|
373
363
|
* @param id The id of the comment regions to act on.
|
|
374
364
|
* @param from The content to replace.
|
|
375
365
|
* @param to The content to replace with.
|
|
@@ -378,6 +368,78 @@ const definitions = [
|
|
|
378
368
|
* @example [](<url>?region=remap(specifier,hello_world,hello_universe,_)
|
|
379
369
|
*/
|
|
380
370
|
"remap(id: string, from: string, to?: string, space?: string)",
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Make the content of the region a single line (where all whitespace characters, including newlines, are converted to a single space).
|
|
374
|
+
* @param id The id of the comment regions to act on.
|
|
375
|
+
* @example [](<url>?region=single-line(specifier))
|
|
376
|
+
*/
|
|
377
|
+
"single-line(id: string, includeBoundaries?: boolean)",
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Trim the whitespace surrounding the comment boundaries of the region.
|
|
381
|
+
* @param id The id of the comment region to act on.
|
|
382
|
+
* @param inside Whether to trim the whitespace within the comment region. Defaults to `true`.
|
|
383
|
+
* @param outside Whether to trim the whitespace outside the comment region. Defaults to `true`.
|
|
384
|
+
* @example [](<url>?region=trim(specifier))
|
|
385
|
+
* @example [](<url>?region=trim(specifier,false))
|
|
386
|
+
* @example [](<url>?region=trim(specifier,,false))
|
|
387
|
+
* @example [](<url>?region=trim(specifier,false,false))
|
|
388
|
+
*/
|
|
389
|
+
"trim(id: string, inside?: boolean, outside?: boolean)",
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Trim the whitespace surrounding the starting comment boundary of the specified region.
|
|
393
|
+
* @param id The id of the comment region to act on.
|
|
394
|
+
* @param left Whether to trim the whitespace to the left of the comment region. Defaults to `true`.
|
|
395
|
+
* @param right Whether to trim the whitespace to the right of the comment region. Defaults to `true`.
|
|
396
|
+
* @example [](<url>?region=trim-start(specifier))
|
|
397
|
+
* @example [](<url>?region=trim-start(specifier,false))
|
|
398
|
+
*/
|
|
399
|
+
"trim-start(id: string, left?: boolean, right?: boolean)",
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Trim the whitespace surrounding the ending comment boundary of the specified region.
|
|
403
|
+
* @param id The id of the comment region to act on.
|
|
404
|
+
* @param left Whether to trim the whitespace to the left of the comment region. Defaults to `true`.
|
|
405
|
+
* @param right Whether to trim the whitespace to the right of the comment region. Defaults to `true`.
|
|
406
|
+
* @example [](<url>?region=trim-end(specifier))
|
|
407
|
+
* @example [](<url>?region=trim-end(specifier,false))
|
|
408
|
+
*/
|
|
409
|
+
"trim-end(id: string, left?: boolean, right?: boolean)",
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Splice the retrieved content at the starting comment boundary of the specified region.
|
|
413
|
+
* @param id The id of the comment region to act on.
|
|
414
|
+
* @param deleteCount The number of characters to delete at either the beginning or end of the comment boundary.
|
|
415
|
+
* Specifying a number greater than or equal to 0 indicates the action should be taken at the end of the comment boundary (i.e to the right of the comment).
|
|
416
|
+
* Specifying undefined or a number less than 0 indicates the action should be taken at the beginning of the comment boundary (i.e to the left of the comment).
|
|
417
|
+
* @param insert The content to insert.
|
|
418
|
+
* @param space The space character to use between words in the content to insert (defaults to `-`).
|
|
419
|
+
*
|
|
420
|
+
* **NOTE:** Content within comments will not be acted upon.
|
|
421
|
+
*/
|
|
422
|
+
"splice-start(id: string, deleteCount?: number, insert?: string, space?: string)",
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Splice the retrieved content at the ending comment boundary of the specified region.
|
|
426
|
+
* @param id The id of the comment region to act on.
|
|
427
|
+
* @param deleteCount The number of characters to delete at either the beginning or end of the comment boundary.
|
|
428
|
+
* Specifying a number greater than or equal to 0 indicates the action should be taken at the end of the comment boundary (i.e to the right of the comment).
|
|
429
|
+
* Specifying undefined or a number less than 0 indicates the action should be taken at the beginning of the comment boundary (i.e to the left of the comment).
|
|
430
|
+
* @param insert The content to insert.
|
|
431
|
+
* @param space The space character to use between words in the content to insert (defaults to `-`).
|
|
432
|
+
*
|
|
433
|
+
* **NOTE:** Content within comments will not be acted upon.
|
|
434
|
+
*/
|
|
435
|
+
"splice-end(id: string, deleteCount?: number, insert?: string, space?: string)",
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* If included at the end of a query, parkdown comments will not be removed from the content after processing.
|
|
439
|
+
* Helpful when trying to determine fine-grained edits (e.g. trimming, splicing, etc.).
|
|
440
|
+
*/
|
|
441
|
+
"debug()"
|
|
442
|
+
|
|
381
443
|
]
|
|
382
444
|
```
|
|
383
445
|
|
|
@@ -690,13 +752,3 @@ depopulateMarkdownInclusions(file, writeFile);
|
|
|
690
752
|
|
|
691
753
|
<!-- p↓ END -->
|
|
692
754
|
<!-- p↓ END -->
|
|
693
|
-
|
|
694
|
-
[](?register=recipe(pkg-replace)®ion=replace(pkg,'''sweater-vest''',_))
|
|
695
|
-
|
|
696
|
-
[](?register=reciple(pk-replace2)&remap(,'''$lib/index.js''','''sweater-vest'''))
|
|
697
|
-
|
|
698
|
-
[](./src?apply=recipe(pkg-replace))
|
|
699
|
-
|
|
700
|
-
[](?register=recipe(single-line-snippet)®ion=single-line(snippet-head),trim(pocket-arg),splice-end(pocket,-2))
|
|
701
|
-
|
|
702
|
-
[](./src?apply=recipe(single-line-snippet))
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Command as r } from "@commander-js/extra-typings";
|
|
3
3
|
import { populateMarkdownInclusions as l, depopulateMarkdownInclusions as a } from "@p-buddy/parkdown";
|
|
4
4
|
import f from "chokidar";
|
|
5
|
-
const c = "0.0.
|
|
5
|
+
const c = "0.0.20", p = new r().version(c).option("--nw, --no-write", "Do NOT write result to file (defaults to false)", !1).option("--ni, --no-inclusions", "Do NOT process file inclusions (defaults to false)", !1).option("-d, --depopulate", "Remove populated inclusions from the file", !1).option("-f, --file <flag>", "The file(s) to process", (e, o) => (o.push(e), o), new Array()).option("-w, --watch", "Watch the file(s) for changes and update automatically", !1).parse(), { inclusions: u, depopulate: d, file: t, write: n, watch: h } = p.opts();
|
|
6
6
|
t.length === 0 && t.push("README.md");
|
|
7
7
|
const m = [
|
|
8
8
|
[l, !u],
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@p-buddy/parkdown",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.20",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"bin": "./dist/cli.js",
|
|
8
8
|
"files": [
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"build": "pnpm run build:lib && pnpm run build:cli",
|
|
37
37
|
"test": "vitest",
|
|
38
38
|
"test:run": "vitest run",
|
|
39
|
-
"cli": "npx tsx src/cli.ts"
|
|
39
|
+
"cli": "npx tsx src/cli.ts",
|
|
40
|
+
"increment": "npm version patch",
|
|
41
|
+
"publish:commit": "git add -u && git commit -m 'chore: regenerate docs and update version'"
|
|
40
42
|
},
|
|
41
43
|
"typings": "./dist/index.d.ts",
|
|
42
44
|
"exports": {
|