@p-buddy/parkdown 0.0.4 → 0.0.5

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,15 +1,16 @@
1
- # parkdown (p)
1
+ # parkdown (p)
2
2
 
3
3
  `parkdown` allows you to include other file's content within your markdown using a link with no text (i.e. `[](<url>)`), where `<url>` corresponds to either:
4
4
  - a local file, e.g. `[](./other.md)` or `[](../root.ts)`
5
5
  - **_COMING SOON_**: An external link
6
6
 
7
- Markdown renderers shouldn't display these links, but [parkdown]() can process and populate them. Also, your editor hopefully makes these links easy to navigate to, improving productivity.
7
+ Markdown renderers shouldn't display these links, but [parkdown](https://www.npmjs.com/package/@p-buddy/parkdown) can process and populate them. Also, your editor hopefully makes these links easy to navigate to, improving productivity.
8
8
 
9
- Collectively, [parkdown]() enables your documentation to behave a little more like code, and for your code to have a rightful place in your documentation.
9
+ Collectively, [parkdown](https://www.npmjs.com/package/@p-buddy/parkdown) enables your documentation to behave a little more like code, and for your code to have a rightful place in your documentation.
10
10
 
11
11
  [](./.assets/invocation.md)
12
- <!-- p BEGIN -->
12
+ <!-- p BEGIN -->
13
+ <!-- p↓ length lines: 29 chars: 796 -->
13
14
  ## Invocation
14
15
 
15
16
  Invoke [parkdown's]() functionality with either the [cli](#cli-inclusions) or via the `processMarkdownIncludes` [export](#populateMarkdownIncludes-export):
@@ -18,28 +19,32 @@ Invoke [parkdown's]() functionality with either the [cli](#cli-inclusions) or vi
18
19
 
19
20
  The following commands are all equivalent:
20
21
  ```bash
21
- npx parkdown --file ./README.md
22
- npx parkdown -f README.md
23
- npx parkdown # defaults to processing inclusions in the 'README.md' file of the current working directory
22
+ npx @p-buddy/parkdown --file ./README.md
23
+ npx @p-buddy/parkdown -f README.md
24
+ npx @p-buddy/parkdown # defaults to processing inclusions in the 'README.md' file of the current working directory
24
25
  ```
25
26
 
26
27
  ### `populateMarkdownIncludes` export
27
28
 
28
- [](.assets/code/inclusions.ts?region=replace(pkg,'''parkdown'''))
29
- <!-- p BEGIN -->
29
+ [](.assets/code/inclusions.ts?region=replace(pkg,'''@p-buddy_slash_parkdown''',_))
30
+ <!-- p BEGIN -->
31
+ <!-- p↓ length lines: 10 chars: 172 -->
32
+
30
33
  ```ts
31
- import { populateMarkdownInclusions } from "parkdown";
34
+ import { populateMarkdownInclusions } from "@p-buddy/parkdown";
32
35
 
33
36
  const file = "README.md";
34
37
  const writeFile = true;
35
38
 
36
39
  populateMarkdownInclusions(file, writeFile);
37
40
  ```
38
- <!-- p▼ END -->
39
- <!-- p END -->
41
+
42
+ <!-- p END -->
43
+ <!-- p↓ END -->
40
44
 
41
45
  [](./.assets/authoring.md)
42
- <!-- p BEGIN -->
46
+ <!-- p BEGIN -->
47
+ <!-- p↓ length lines: 558 chars: 17214 -->
43
48
  ## Authoring
44
49
 
45
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`).
@@ -57,84 +62,110 @@ There are two equivalent ways to author inline inclusions, [single-line](#single
57
62
  What you write:
58
63
 
59
64
  [](.assets/unpopulated/inline.single.md?wrap=code)
60
- <!-- p BEGIN -->
65
+ <!-- p BEGIN -->
66
+ <!-- p↓ length lines: 5 chars: 40 -->
67
+
61
68
  ```md
62
69
  Before... [](<url>) ...After
63
70
  ```
64
- <!-- p▼ END -->
65
71
 
66
- What is rendered (**_before_** processing, same as [Option B](#option-b-multi-line)):
72
+ <!-- p↓ END -->
73
+
74
+ <details>
75
+ <summary>See rendering and processing output</summary>
76
+
77
+ What is rendered (**_before_** processing, same as [Multi-line](#multi-line)):
67
78
 
68
79
  [](.assets/unpopulated/inline.single.md?wrap=quote&inline)
69
- <!-- p BEGIN -->
80
+ <!-- p BEGIN -->
81
+ <!-- p↓ length lines: 1 chars: 30 -->
70
82
  > Before... [](<url>) ...After
71
- <!-- p END -->
83
+ <!-- p END -->
72
84
 
73
85
  What your markdown file contains (**_after_** processing):
74
86
 
75
87
  [](.assets/populated/inline.single.md?wrap=code)
76
- <!-- p BEGIN -->
88
+ <!-- p BEGIN -->
89
+ <!-- p↓ length lines: 7 chars: 120 -->
90
+
77
91
  ```md
78
- Before... [](<url>) <!-- p Begin -->
92
+ Before... [](<url>) <!-- p Begin -->
79
93
  ...Included Content...
80
- ...Included Content... <!-- p End --> ...After
94
+ ...Included Content... <!-- p End --> ...After
81
95
  ```
82
- <!-- p▼ END -->
83
96
 
84
- What is rendered (**_after_** processing, same as [Option B](#option-b-multi-line)):
97
+ <!-- p↓ END -->
98
+
99
+ What is rendered (**_after_** processing, same as [Multi-line](#multi-line)):
85
100
 
86
101
  [](.assets/populated/inline.single.md?wrap=quote&inline)
87
- <!-- p BEGIN -->
88
- > Before... [](<url>) <!-- p▼ Begin -->
102
+ <!-- p BEGIN -->
103
+ <!-- p↓ length lines: 3 chars: 110 -->
104
+ > Before... [](<url>) <!-- p↓ Begin -->
89
105
  ...Included Content...
90
- ...Included Content... <!-- p End --> ...After
91
- <!-- p END -->
106
+ ...Included Content... <!-- p End --> ...After
107
+ <!-- p END -->
108
+
109
+ </details>
92
110
 
93
111
  #### Multi-line
94
112
 
95
113
  What you write:
96
114
 
97
115
  [](.assets/unpopulated/inline.multi.md?wrap=code)
98
- <!-- p BEGIN -->
116
+ <!-- p BEGIN -->
117
+ <!-- p↓ length lines: 7 chars: 41 -->
118
+
99
119
  ```md
100
120
  Before...
101
121
  [](<url>)
102
122
  ...After
103
123
  ```
104
- <!-- p▼ END -->
105
124
 
106
- What is rendered (**_before_** processing, same as [Option A](#option-a-single-line)):
125
+ <!-- p↓ END -->
126
+
127
+ <details>
128
+ <summary>See rendering and processing output</summary>
129
+
130
+ What is rendered (**_before_** processing, same as [Single-line](#single-line)):
107
131
 
108
132
  [](.assets/unpopulated/inline.multi.md?wrap=quote&inline)
109
- <!-- p BEGIN -->
133
+ <!-- p BEGIN -->
134
+ <!-- p↓ length lines: 3 chars: 31 -->
110
135
  > Before...
111
136
  [](<url>)
112
137
  ...After
113
- <!-- p END -->
138
+ <!-- p END -->
114
139
 
115
140
  What your markdown file contains (**_after_** processing):
116
141
 
117
142
  [](.assets/populated/inline.multi.md?wrap=code)
118
- <!-- p BEGIN -->
143
+ <!-- p BEGIN -->
144
+ <!-- p↓ length lines: 9 chars: 122 -->
145
+
119
146
  ```md
120
147
  Before...
121
- [](<url>) <!-- p Begin -->
148
+ [](<url>) <!-- p Begin -->
122
149
  ...Included Content...
123
- ...Included Content... <!-- p End -->
150
+ ...Included Content... <!-- p End -->
124
151
  ...After
125
152
  ```
126
- <!-- p▼ END -->
127
153
 
128
- What is rendered (**_after_** processing, same as [Option A](#option-a-single-line)):
154
+ <!-- p↓ END -->
155
+
156
+ What is rendered (**_after_** processing, same as [Single-line](#single-line)):
129
157
 
130
158
  [](.assets/populated/inline.multi.md?wrap=quote&inline)
131
- <!-- p BEGIN -->
159
+ <!-- p BEGIN -->
160
+ <!-- p↓ length lines: 5 chars: 112 -->
132
161
  > Before...
133
- [](<url>) <!-- p Begin -->
162
+ [](<url>) <!-- p Begin -->
134
163
  ...Included Content...
135
- ...Included Content... <!-- p End -->
164
+ ...Included Content... <!-- p End -->
136
165
  ...After
137
- <!-- p END -->
166
+ <!-- p END -->
167
+
168
+ </details>
138
169
 
139
170
  ### Block
140
171
 
@@ -143,7 +174,9 @@ Block inclusions occur when your "empty" link is the **only** node in a [paragra
143
174
  What you write:
144
175
 
145
176
  [](.assets/unpopulated/block.md?wrap=code)
146
- <!-- p BEGIN -->
177
+ <!-- p BEGIN -->
178
+ <!-- p↓ length lines: 9 chars: 42 -->
179
+
147
180
  ```md
148
181
  Before...
149
182
 
@@ -151,12 +184,18 @@ Before...
151
184
 
152
185
  ...After
153
186
  ```
154
- <!-- p▼ END -->
187
+
188
+ <!-- p↓ END -->
189
+
190
+ <details>
191
+ <summary>See rendering and processing output</summary>
155
192
 
156
193
  What is rendered (**_before_** processing):
157
194
 
158
195
  [](.assets/unpopulated/block.md?wrap=quote)
159
- <!-- p BEGIN -->
196
+ <!-- p BEGIN -->
197
+ <!-- p↓ length lines: 11 chars: 61 -->
198
+
160
199
  <blockquote>
161
200
 
162
201
  Before...
@@ -167,47 +206,55 @@ Before...
167
206
 
168
207
  </blockquote>
169
208
 
170
- <!-- p END -->
209
+ <!-- p END -->
171
210
 
172
211
  What your markdown file contains (**_after_** processing):
173
212
 
174
213
  [](.assets/populated/block.md?wrap=code)
175
- <!-- p BEGIN -->
214
+ <!-- p BEGIN -->
215
+ <!-- p↓ length lines: 13 chars: 124 -->
216
+
176
217
  ```md
177
218
  Before...
178
219
 
179
220
  [](<url>)
180
- <!-- p Begin -->
221
+ <!-- p Begin -->
181
222
  ...Included Content...
182
223
  ...Included Content...
183
- <!-- p End -->
224
+ <!-- p End -->
184
225
 
185
226
  ...After
186
227
  ```
187
- <!-- p▼ END -->
228
+
229
+ <!-- p↓ END -->
188
230
 
189
231
  What is rendered (**_after_** processing):
190
232
 
191
233
  [](.assets/populated/block.md?wrap=quote)
192
- <!-- p BEGIN -->
234
+ <!-- p BEGIN -->
235
+ <!-- p↓ length lines: 15 chars: 143 -->
236
+
193
237
  <blockquote>
194
238
 
195
239
  Before...
196
240
 
197
241
  [](<url>)
198
- <!-- p Begin -->
242
+ <!-- p Begin -->
199
243
  ...Included Content...
200
244
  ...Included Content...
201
- <!-- p End -->
245
+ <!-- p End -->
202
246
 
203
247
  ...After
204
248
 
205
249
  </blockquote>
206
250
 
207
- <!-- p END -->
251
+ <!-- p END -->
252
+
253
+ </details>
208
254
 
209
255
  [](.assets/query.md?heading=-1)
210
- <!-- p BEGIN -->
256
+ <!-- p BEGIN -->
257
+ <!-- p↓ length lines: 347 chars: 12711 -->
211
258
  ### Query parameters
212
259
 
213
260
  You can pass query parameters to your inclusion links to control how their content is processed and included within your markdown.
@@ -215,7 +262,9 @@ You can pass query parameters to your inclusion links to control how their conte
215
262
  #### Processing Order
216
263
 
217
264
  [](src/include.ts?&region=extract(query))
218
- <!-- p BEGIN -->
265
+ <!-- p BEGIN -->
266
+ <!-- p↓ length lines: 10 chars: 322 -->
267
+
219
268
  ```ts
220
269
  const params = new URLSearchParams(query);
221
270
  const regions = params.get("region")?.split(COMMA_NOT_IN_PARENTHESIS);
@@ -224,7 +273,8 @@ const headingModfiier = params.get("heading") ?? 0;
224
273
  const inlineOverride = params.has("inline");
225
274
  const wraps = params.get("wrap")?.split(COMMA_NOT_IN_PARENTHESIS);
226
275
  ```
227
- <!-- p▼ END -->
276
+
277
+ <!-- p↓ END -->
228
278
 
229
279
  #### `region`
230
280
 
@@ -238,14 +288,16 @@ Specifiers will be searched for within the file's comments, and are expected to
238
288
  /** some-specifier */
239
289
  ```
240
290
 
241
- ```md
242
- [](...?region=extract(some-specifier))
243
- ```
291
+ 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:
244
292
 
245
- 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 (e.g. `[](<url>?region=extract(some-specifier))`, `[](<url>?region=remove(some-specifier))`, `[](<url>?region=replace(some-specifier))`).
293
+ - `[](<url>?region=extract(some-specifier))`
294
+ - `[](<url>?region=remove(some-specifier))`
295
+ - `[](<url>?region=replace(some-specifier,replacement-content))`
246
296
 
247
297
  [](.assets/api-note.md?wrap=quote)
248
- <!-- p BEGIN -->
298
+ <!-- p BEGIN -->
299
+ <!-- p↓ length lines: 9 chars: 352 -->
300
+
249
301
  <blockquote>
250
302
 
251
303
  **_NOTE ON API USAGE:_** As you can see from the included examples, each _invocation_ of an API method looks like a less strict (more quirky) version of a typical javascript function invocation.
@@ -254,28 +306,61 @@ Please see the [full explanation](#query-parameters-with-function-like-apis) to
254
306
 
255
307
  </blockquote>
256
308
 
257
- <!-- p END -->
309
+ <!-- p END -->
258
310
 
259
311
  [](src/region.ts?region=extract(definition))
260
- <!-- p BEGIN -->
312
+ <!-- p BEGIN -->
313
+ <!-- p↓ length lines: 36 chars: 1651 -->
314
+
261
315
  ```ts
262
316
  const definitions = [
317
+ /**
318
+ * Extract regions from the retrieved content between comments that INCLUDE the specified ids.
319
+ * @param id The id of the comment to extract.
320
+ * @param 0 An optional additional id to extract.
321
+ * @param 1 An optional additional id to extract.
322
+ * @param 2 An optional additional id to extract.
323
+ * @example [](<url>?region=extract(specifier))
324
+ * @example [](<url>?region=extract(specifier,other-specifier,some-other-specifier))
325
+ */
263
326
  "extract(id: string, 0?: string, 1?: string, 2?: string)",
327
+ /**
328
+ * Remove regions from the retrieved content between comments that INCLUDE the specified ids.
329
+ * @param id The id of the comment to remove.
330
+ * @param 0 An optional additional id to remove.
331
+ * @param 1 An optional additional id to remove.
332
+ * @param 2 An optional additional id to remove.
333
+ * @example [](<url>?region=remove(specifier))
334
+ * @example [](<url>?region=remove(specifier,other-specifier,some-other-specifier))
335
+ */
264
336
  "remove(id: string, 0?: string, 1?: string, 2?: string)",
337
+ /**
338
+ * Replace regions from the retrieved content between comments that INCLUDE the specified ids.
339
+ * @param id The id of the comment to replace.
340
+ * @param with The replacement content (if ommitted, the content of the detected comment will be used).
341
+ * @param space The space character to use between words in the replacement content (defaults to `-`).
342
+ * @example [](<url>?region=replace(specifier))
343
+ * @example [](<url>?region=replace(specifier,new-content))
344
+ * @example [](<url>?region=replace(specifier,new_content,_)
345
+ */
265
346
  "replace(id: string, with?: string, space?: string)",
266
347
  ]
267
348
  ```
268
- <!-- p▼ END -->
349
+
350
+ <!-- p↓ END -->
269
351
 
270
352
  #### `skip`
271
353
 
272
354
  Skip the default processing behavior for the given type of file.
273
355
 
274
356
  [](src/include.ts?wrap=dropdown(See-default-processing-behavior.)&region=extract(Default-Behavior),replace(...))
275
- <!-- p BEGIN -->
357
+ <!-- p BEGIN -->
358
+ <!-- p↓ length lines: 17 chars: 267 -->
276
359
 
277
360
  <details>
278
- <summary>See default processing behavior.</summary>
361
+ <summary>
362
+ See default processing behavior.
363
+ </summary>
279
364
 
280
365
  ```ts
281
366
  if (extension === "md") {
@@ -285,9 +370,10 @@ if (extension === "md") {
285
370
  else if (/^(js|ts)x?|svelte$/i.test(extension))
286
371
  content = wrap(content, "code", ...);
287
372
  ```
373
+
288
374
  </details>
289
375
 
290
- <!-- p END -->
376
+ <!-- p END -->
291
377
 
292
378
  ```md
293
379
  [](<url>?skip)
@@ -295,36 +381,66 @@ else if (/^(js|ts)x?|svelte$/i.test(extension))
295
381
 
296
382
  #### `heading`
297
383
 
298
- Modify the heading depth applied to included content. By default, the headings of the included content are adjusted to be one-level below their parent heading.
384
+ Modify the heading depth applied to included content. By default, the headings of the included content are adjusted to be one-level below their parent heading (i.e. the heading the included content falls under).
299
385
 
300
- In the following example, the headings within the included content of `<url>` will be adjusted to one-level below the parent heading (which is an `h2` / `##`), so any `#` headings will be converted to `###` headings, and `##` headings will be converted to `####` headings, and so on.
386
+ You might commonly see `[](<url>?heading=-1)` used to ensure that the included content's heading level is the same as it's parent heading.
387
+
388
+ <details>
389
+ <summary>
390
+ See example usage:
391
+ </summary>
392
+ Assuming you have the following markdown files:
301
393
 
302
394
  ```md
303
- ## Heading
395
+ <!-- to-be-included.md -->
396
+ # Included Heading
397
+ ```
304
398
 
305
- [](<url>)
399
+ ```md
400
+ <!-- README.md -->
401
+ # Heading
402
+
403
+ [](./to-be-included.md)
306
404
  ```
307
405
 
308
- The following would then ensure that the headings of the included content are at the same level as the parent heading.
406
+ When `README.md` is processed, it will be transformed into the following:
309
407
 
310
408
  ```md
311
- ## Heading
409
+ # Heading
312
410
 
313
- [](<url>?heading=-1)
411
+ ## Included Heading
314
412
  ```
315
413
 
316
- A value of `-2` would result in the headings of the included content being at their original level (since the content is being included underneath an `h2` / `##` heading).
414
+ Where the included content's heading has been modified to be one-level below the parent heading (i.e. it is converted from an `h1` / `#` heading to a `h2` / `##` heading — `h1 + 1 = h2`).
415
+
416
+ If we instead wanted the included heading to remain a `h1` / `#` heading, we'd make use of the `heading` query parameter with a value of `-1` (since `h1 + 1 - 1 = h1`), like so:
417
+
418
+ ```md
419
+ <!-- README.md -->
420
+ # Heading
421
+
422
+ [](./to-be-included.md?heading=-1)
423
+ ```
424
+
425
+ </details>
317
426
 
318
427
  #### `inline` (Advanced)
319
428
 
429
+ Force a replacement target to be treated as [inline](#inline) content.
430
+
320
431
  #### `wrap`
321
432
 
322
433
  Wrap the content of the included file in a specific kind of element.
323
434
 
324
- Below is the currently supported API for the `wrap` query parameter, where each defined method signature can be _invoked_ as a value for the `wrap` parameter (e.g. `[](<url>?wrap=code)`, `[](<url>?wrap=dropdown(hello-world))`).
435
+ Below is the currently supported API for the `wrap` query parameter, where each defined method signature can be _invoked_ as a value for the `wrap` parameter, for example:
436
+
437
+ - `[](<url>?wrap=code)`
438
+ - `[](<url>?wrap=dropdown(hello-world))`
325
439
 
326
440
  [](.assets/api-note.md?wrap=quote)
327
- <!-- p BEGIN -->
441
+ <!-- p BEGIN -->
442
+ <!-- p↓ length lines: 9 chars: 352 -->
443
+
328
444
  <blockquote>
329
445
 
330
446
  **_NOTE ON API USAGE:_** As you can see from the included examples, each _invocation_ of an API method looks like a less strict (more quirky) version of a typical javascript function invocation.
@@ -333,10 +449,12 @@ Please see the [full explanation](#query-parameters-with-function-like-apis) to
333
449
 
334
450
  </blockquote>
335
451
 
336
- <!-- p END -->
452
+ <!-- p END -->
337
453
 
338
454
  [](src/wrap.ts?region=extract(definition))
339
- <!-- p BEGIN -->
455
+ <!-- p BEGIN -->
456
+ <!-- p↓ length lines: 38 chars: 1384 -->
457
+
340
458
  ```ts
341
459
  const definitions = [
342
460
  /**
@@ -373,13 +491,123 @@ const definitions = [
373
491
 
374
492
  ]
375
493
  ```
376
- <!-- p▼ END -->
377
494
 
378
- <!-- p END -->
379
- <!-- p▼ END -->
495
+ <!-- p END -->
496
+
497
+ [](.assets/api.md?heading=-1)
498
+ <!-- p↓ BEGIN -->
499
+ <!-- p↓ length lines: 104 chars: 4981 -->
500
+ #### Query Parameters with Function-like APIs
501
+
502
+ 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:
503
+
504
+ ```ts
505
+ const definitions = [
506
+ "method(arg1: string, arg2: boolean, arg3?: number)",
507
+ "otherMethod(arg1: string, arg2?: boolean, arg3?: number)"
508
+ ]
509
+ ```
510
+
511
+ These APIs are utilized when setting the value of the specific query parameter with a _function-like_ invocation syntax, such as:
512
+
513
+ ```md
514
+ [](<url>?example=method(hello-world,true))
515
+ ```
516
+
517
+ As you can see from the example above, we're relaxing some constraints on typical function invocations (like the need to wrap string arguments in quotes), while also imposing some additional constraints (like not using _any_ spaces) to ensure the links are valid markdown and the URLs are [safe](https://support.exactonline.com/community/s/knowledge-base?language=en_GB#All-All-DNO-Content-urlcharacters).
518
+
519
+ The goal is to make it as painless as possible to author links that are valid markdown, valid URLs, and easy to read and write.
520
+
521
+ Please note the following:
522
+
523
+ - Methods that take no arguments can be invoked without parentheses (e.g. `[](<url>?example=method)`).
524
+ - String arguments do not need to be wrapped in quotes (e.g. `[](<url>?example=method(some-string))`), and they **CANNOT** be wrapped in double quotes (see more below).
525
+ - You cannot use spaces within a string argument or anywhere else in the query (as this would violate the markdown link syntax). For arguments that reasonably could include spaces, there should be an optional `space` argument that defaults to `-`, so that any usage of the space character will be converted to a space (e.g. `hello-world` becomes `hello world`).
526
+ - Characters that are reserved or unsafe in URLs can be included by using the below remapping, where you'll write the corresponding key wrapped in the applicable `space` character (see the above bullet point, defaults to `-`). For example, if you want to use a `/`, you'd instead write `-slash-` (or with whatever you specify as your space character instead of `-`).
527
+
528
+ [](src/utils.ts?region=extract(url))
529
+ <!-- p↓ BEGIN -->
530
+ <!-- p↓ length lines: 31 chars: 498 -->
531
+
532
+ ```ts
533
+ const urlCharacters = {
534
+ reserved: {
535
+ ["semi"]: ";",
536
+ ["slash"]: "/",
537
+ ["question"]: "?",
538
+ ["colon"]: ":",
539
+ ["at"]: "@",
540
+ ["equal"]: "=",
541
+ ["and"]: "&",
542
+ },
543
+ unsafe: {
544
+ ["quote"]: "\"",
545
+ ["angle"]: "<",
546
+ ["unangle"]: ">",
547
+ ["hash"]: "#",
548
+ ["percent"]: "%",
549
+ ["curly"]: "{",
550
+ ["uncurly"]: "}",
551
+ ["pipe"]: "|",
552
+ ["back"]: "\\",
553
+ ["carrot"]: "^",
554
+ ["tilde"]: "~",
555
+ ["square"]: "[",
556
+ ["unsquare"]: "]",
557
+ ["tick"]: "`",
558
+ }
559
+ }
560
+ ```
561
+
562
+ <!-- p↓ END -->
563
+
564
+ - If a method takes a string argument, and you want to include a comma within that argument, you must wrap it in one or more single quotes (e.g.`hello,-world` should be specified as `'hello,-world'`).
565
+ - String arguments wrapped in a single set of single quotes will automatically have the quotes removed when the query is parsed (e.g. the argument included in `[](<url>?example=method('hello,world'))` will parse to `hello,world`).
566
+ - If you want single quotes preserved in the parsed output, use two single quotes in a row (e.g. `[](<url>?example=method(''single-quoted''))`).
567
+ - You cannot use double quotes within a string argument (as they are not a [URL safe character](https://support.exactonline.com/community/s/knowledge-base#All-All-DNO-Content-urlcharacters)). To include a double-quote in the parsed output, use three single quotes in a row (e.g. `[](<url>?example=method('''double-quoted'''))`). Or use the remapping described above, like `[](<url>?example=method(-quote-double-quoted-quote-))`.
568
+ - Optional arguments can be completely ommitted (for example if a `method` took 3 optional arguments, and you only wanted to provide the third, you could do the following: `[](<url>?example=method(,,your-third-argument))`).
569
+ - Overall, text meant to be displayed will be _sanitized_ in the following manner (unless otherwise noted):
570
+
571
+ [](src/utils.ts?region=extract(sanitize))
572
+ <!-- p↓ BEGIN -->
573
+ <!-- p↓ length lines: 29 chars: 779 -->
574
+
575
+ ```ts
576
+ type Replacement = [from: RegExp | string, to: string];
577
+
578
+ const replacements: Record<string, Replacement[]> = {
579
+ static: [
580
+ [`'''`, `"`],
581
+ [`''`, `'`],
582
+ [/parkdown:\s+/g, ``],
583
+ [/p↓:\s+/g, ``],
584
+ ],
585
+ url: [
586
+ ...(Object.entries(urlCharacters.unsafe)),
587
+ ...(Object.entries(urlCharacters.reserved))
588
+ ]
589
+ };
590
+
591
+ const applyReplacement = (accumulator: string, [from, to]: Replacement) =>
592
+ accumulator.replaceAll(from, to);
593
+
594
+ export const sanitize = (replacement: string, space: string = DEFAULT_SPACE) => {
595
+ const sanitized = replacements.static.reduce(applyReplacement, replacement)
596
+ return replacements.url
597
+ .map(([key, to]) => ([space + key + space, to] satisfies Replacement))
598
+ .reduce(applyReplacement, sanitized)
599
+ .replaceAll(space, " ");
600
+ }
601
+ ```
602
+
603
+ <!-- p↓ END -->
604
+ <!-- p↓ END -->
605
+ <!-- p↓ END -->
606
+ <!-- p↓ END -->
380
607
 
381
608
  [](./.assets/depopulated.md)
382
- <!-- p BEGIN -->
609
+ <!-- p BEGIN -->
610
+ <!-- p↓ length lines: 38 chars: 1473 -->
383
611
  ## Removing populated inclusions
384
612
 
385
613
  Sometimes you may want to remove populated inclusions from your markdown file, since they can make things more difficult to read during authoring. You can do this either using the [cli](#cli-removing-populated-inclusions) or via the `removePopulatedInclusions` [export](#depopulateMarkdownIncludes-export):
@@ -389,30 +617,33 @@ Sometimes you may want to remove populated inclusions from your markdown file, s
389
617
  The following commands are all equivalent:
390
618
 
391
619
  ```bash
392
- npx parkdown --file ./README.md --depopulate --no-inclusions
393
- npx parkdown -f README.md -d --ni # Notice the double-dash (--) on 'ni'
394
- npx parkdown -d --ni # defaults to processing the 'README.md' file of the current working directory
620
+ npx @p-buddy/parkdown --file ./README.md --depopulate --no-inclusions
621
+ npx @p-buddy/parkdown -f README.md -d --ni # Notice the double-dash (--) on 'ni'
622
+ npx @p-buddy/parkdown -d --ni # defaults to processing the 'README.md' file of the current working directory
395
623
  ```
396
624
 
397
625
  The following commands will lead to the same result, but since `--no-inclusions` (`--ni`) is not specified, there will be some wasted work as inclusions will be processed and then removed.
398
626
 
399
627
  ```bash
400
- npx parkdown --file ./README.md --depopulate
401
- npx parkdown -f README.md -d
402
- npx parkdown -d # defaults to processing the 'README.md' file of the current working directory
628
+ npx @p-buddy/parkdown --file ./README.md --depopulate
629
+ npx @p-buddy/parkdown -f README.md -d
630
+ npx @p-buddy/parkdown -d # defaults to processing the 'README.md' file of the current working directory
403
631
  ```
404
632
 
405
633
  ### `depopulateMarkdownIncludes` export
406
634
 
407
- [](.assets/code/depopulate.ts?region=replace(pkg,'''parkdown'''))
408
- <!-- p BEGIN -->
635
+ [](.assets/code/depopulate.ts?region=replace(pkg,'''@p-buddy_slash_parkdown''',_))
636
+ <!-- p BEGIN -->
637
+ <!-- p↓ length lines: 10 chars: 176 -->
638
+
409
639
  ```ts
410
- import { depopulateMarkdownInclusions } from "parkdown";
640
+ import { depopulateMarkdownInclusions } from "@p-buddy/parkdown";
411
641
 
412
642
  const file = "README.md";
413
643
  const writeFile = true;
414
644
 
415
645
  depopulateMarkdownInclusions(file, writeFile);
416
646
  ```
417
- <!-- p▼ END -->
418
- <!-- p END -->
647
+
648
+ <!-- p END -->
649
+ <!-- p↓ END -->