@p-buddy/parkdown 0.0.12 → 0.0.14
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 +51 -14
- package/dist/cli.js +12 -11
- package/dist/index.d.ts +6 -2
- package/dist/index.js +498 -318
- package/dist/index.umd.cjs +15 -14
- package/package.json +2 -1
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: 601 chars: 19975 -->
|
|
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: 388 chars: 15269 -->
|
|
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.
|
|
@@ -290,6 +290,8 @@ Specifiers will be searched for within the file's comments, and are expected to
|
|
|
290
290
|
/** some-specifier */
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
+
Identifiers will be searched for within the text of a comment split by spaces (i.e. `some-specifier` is a single identifier, but `some specifier` represents two separate identifiers).
|
|
294
|
+
|
|
293
295
|
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:
|
|
294
296
|
|
|
295
297
|
- `[](<url>?region=extract(some-specifier))`
|
|
@@ -314,7 +316,7 @@ Please see the [full explanation](#query-parameters-with-function-like-apis) to
|
|
|
314
316
|
|
|
315
317
|
[](src/region.ts?region=extract(definition))
|
|
316
318
|
<!-- p↓ BEGIN -->
|
|
317
|
-
<!-- p↓ length lines:
|
|
319
|
+
<!-- p↓ length lines: 64 chars: 3718 -->
|
|
318
320
|
|
|
319
321
|
```ts
|
|
320
322
|
const definitions = [
|
|
@@ -348,6 +350,34 @@ const definitions = [
|
|
|
348
350
|
* @example [](<url>?region=replace(specifier,new_content,_)
|
|
349
351
|
*/
|
|
350
352
|
"replace(id: string, with?: string, space?: string)",
|
|
353
|
+
/**
|
|
354
|
+
* Splice the retrieved content at the boundary of a comment region (which must INCLUDE the specified id).
|
|
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.
|
|
373
|
+
* @param id The id of the comment regions to act on.
|
|
374
|
+
* @param from The content to replace.
|
|
375
|
+
* @param to The content to replace with.
|
|
376
|
+
* @param space The space character to use between words in the content to replace (defaults to `-`).
|
|
377
|
+
* @example [](<url>?region=remap(specifier,hello-world,hello-universe))
|
|
378
|
+
* @example [](<url>?region=remap(specifier,hello_world,hello_universe,_)
|
|
379
|
+
*/
|
|
380
|
+
"remap(id: string, from: string, to?: string, space?: string)",
|
|
351
381
|
]
|
|
352
382
|
```
|
|
353
383
|
|
|
@@ -359,7 +389,7 @@ Skip the default processing behavior for the given type of file.
|
|
|
359
389
|
|
|
360
390
|
[](src/include.ts?wrap=dropdown(See-default-processing-behavior.)®ion=extract(Default-Behavior),replace(...))
|
|
361
391
|
<!-- p↓ BEGIN -->
|
|
362
|
-
<!-- p↓ length lines:
|
|
392
|
+
<!-- p↓ length lines: 17 chars: 273 -->
|
|
363
393
|
|
|
364
394
|
<details>
|
|
365
395
|
<summary>
|
|
@@ -368,15 +398,11 @@ See default processing behavior.
|
|
|
368
398
|
|
|
369
399
|
```ts
|
|
370
400
|
if (extension === "md") {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const relative = basePath ? join(basePath, dir) : dir;
|
|
374
|
-
const depth = clampHeadingSum(headingDepth, Number(headingModfiier));
|
|
375
|
-
|
|
376
|
-
content = recursivelyPopulateInclusions(content, depth, getContent, path, relative);
|
|
401
|
+
* ...
|
|
402
|
+
content = recursivelyPopulateInclusions(content, * ...);
|
|
377
403
|
}
|
|
378
404
|
else if (/^(js|ts)x?|svelte$/i.test(extension))
|
|
379
|
-
content = wrap(content, "code",
|
|
405
|
+
content = wrap(content, "code", * ...);
|
|
380
406
|
```
|
|
381
407
|
|
|
382
408
|
</details>
|
|
@@ -512,7 +538,7 @@ const definitions = [
|
|
|
512
538
|
|
|
513
539
|
[](.assets/api.md?heading=-1)
|
|
514
540
|
<!-- p↓ BEGIN -->
|
|
515
|
-
<!-- p↓ length lines:
|
|
541
|
+
<!-- p↓ length lines: 105 chars: 4993 -->
|
|
516
542
|
#### Query Parameters with Function-like APIs
|
|
517
543
|
|
|
518
544
|
Some query parameters have more complex APIs, which are defined by a collection of typescript function singatures (limited to only `string`, `boolean`, and `number` arguments), like:
|
|
@@ -543,7 +569,7 @@ Please note the following:
|
|
|
543
569
|
|
|
544
570
|
[](src/utils.ts?region=extract(url))
|
|
545
571
|
<!-- p↓ BEGIN -->
|
|
546
|
-
<!-- p↓ length lines:
|
|
572
|
+
<!-- p↓ length lines: 32 chars: 518 -->
|
|
547
573
|
|
|
548
574
|
```ts
|
|
549
575
|
const urlCharacters = {
|
|
@@ -571,6 +597,7 @@ const urlCharacters = {
|
|
|
571
597
|
["square"]: "[",
|
|
572
598
|
["unsquare"]: "]",
|
|
573
599
|
["tick"]: "`",
|
|
600
|
+
["line"]: "\n",
|
|
574
601
|
}
|
|
575
602
|
}
|
|
576
603
|
```
|
|
@@ -662,4 +689,14 @@ depopulateMarkdownInclusions(file, writeFile);
|
|
|
662
689
|
```
|
|
663
690
|
|
|
664
691
|
<!-- p↓ END -->
|
|
665
|
-
<!-- p↓ END -->
|
|
692
|
+
<!-- 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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command as
|
|
3
|
-
import { populateMarkdownInclusions as l, depopulateMarkdownInclusions as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[
|
|
2
|
+
import { Command as r } from "@commander-js/extra-typings";
|
|
3
|
+
import { populateMarkdownInclusions as l, depopulateMarkdownInclusions as a } from "@p-buddy/parkdown";
|
|
4
|
+
import f from "chokidar";
|
|
5
|
+
const c = "0.0.14", 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
|
+
t.length === 0 && t.push("README.md");
|
|
7
|
+
const m = [
|
|
8
|
+
[l, !u],
|
|
9
|
+
[a, d]
|
|
9
10
|
];
|
|
10
|
-
for (const [
|
|
11
|
-
for (const o of
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
for (const [e] of m.filter(([o, s]) => s))
|
|
12
|
+
for (const o of t) {
|
|
13
|
+
const s = h ? f.watch([], { persistent: !0, awaitWriteFinish: !0, atomic: !0 }) : void 0, i = e(o, !n, s);
|
|
14
|
+
n && console.log(i);
|
|
14
15
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { default as default_2 } from 'chokidar';
|
|
2
2
|
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const depopulateMarkdownInclusions: (file: string, writeFile?: boolean, watcher?: Watcher) => string;
|
|
4
|
+
|
|
5
|
+
export declare const populateMarkdownInclusions: (file: string, writeFile?: boolean, watcher?: Watcher) => string;
|
|
6
|
+
|
|
7
|
+
declare type Watcher = ReturnType<typeof default_2.watch>;
|
|
4
8
|
|
|
5
9
|
export { }
|